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
I want to store more than 10 objects in a remote server? Which methodology will follow?
How to sort a collection of custom Objects in Java?
What is meant by call by reference?
What is method and methodology?
How to print an arraylist in java?
How to obtain a performance profile of java program
What is the range of the short type?
Can list contain null in java?
Which class represents the socket that both the client and server use to communicate with each other?
Is java programming easy?
What is singleton math?
Write an algorithm program in java for the following question.. In a VLSI design techniques,they used rectangles to design circuits. EVery rectangle is to be placed according to x,y coordinates. Check whether or not two rectangles overlap each other. Here overlapping of rectangles is acceptable, if 1) one rectangle intersect with other. 2) one rectangle fully covers other. The time of algorithm should not exceed o(n logn).
What is update method called?
Explain the difference between string, stringbuffer and stringbuilder in java?
Is object a data type?