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
What is the longest unicode character?
What is bytecode verifier?
What are the advantages of java inner classes?
What is initial size of arraylist in java?
What is java in simple terms?
Why java is a platform independent? Explain
What is array sorting in java?
Define interface in java?
What is constructor and its types?
Do I need java on my computer?
Can we override compareto method?
What do you mean by a JVM?
Which access specifier can be used with class ?
How do you add an arraylist to an array in java?
What is string [] java?