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 benefit of using enum to declare a constant?
What is a literal coding?
What are the advantages of exception handling in java?
How to display all the prime numbers between 1 and 100
Explain methods specific to list interface?
If a class is declared without any access modifiers, where may the class be accessed in java programming?
Why is multithreading important?
What is the final keyword in java?
What do you mean by singleton class in java?
Define linked list and its features with signature?
Can constructor be static or final?
What flag up means?
if u open login & logout ,how can udisplay the timelogin & logout members ?
What is java string pool?
What was java originally called?