what is overloading in java?
Answer Posted / binod kumar
IF WE HAVE SAME METHOD NAME WITH DIFFERENT TYPES OF PARAMETERS THEN IT IS KNOWN AS METHOD OVERLOADING.
EXAMPLE----------->
class A
{
void sum(int a,int b)
{
int s=a+b;
System.out.println("Sum of a+b is:" +s);
}
void sum(int x,int y,int z)
{
int s2=x+y+z;
System.out.println("Sum of x+y+z is:" +s2);
}
}
class ovrloading
{
public static void main(String str[])
{
A a=new A();
a.sum(10,20);
a.sum(10,20,30);
}
}
IN GIVEN EXAMPLE WE HAVE SUM METHOD WITH DIFF PARAMETERS.
OUTOUT WILL BE------->
Sum of a+b is: 30
Sum of x+y+z is: 60
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain different ways of creating a thread?
can java object be locked down for exclusive use by a given thread? : Java thread
What does int argc char * argv [] mean?
what do you mean by classloader in java?
What is the gregoriancalendar class in java programming?
Explain about anonymous inner classes ?
Does java arraylist maintain insertion order?
What is an enumeration?
Are arrays immutable in java?
What are untrusted applets?
Differences between C and Java?
What is difference between Heap and Stack Memory?
What are methods and how are they defined?
What is the purpose of javac exe?
What is the purpose of return statement?