what is overloading in java?

Answer Posted / srujana

To define one or more methods within the same class that
share the same name, as long as thier parameters
declarations are diffrent.These methods are called
overloaded and its process is called Methodoverloading.
For example,
class Demo
{
void test()
{
System.out.println("No parameters");
}
void test(int a)
{
System.out.println("a is:"+a);
}
void test(int a, int b)
{
System.out.println("a is:"+a "," +b);
}
}
class Demo1
{
public static void main(String args[])
{
Demo1 d=new Demo();
d.test();
d.test(5);
d.test(2,3);
}
}

Is This Answer Correct ?    27 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between static and non-static methods in java.

830


What is the syntax and characteristics of a lambda expression?

830


Is java based on c?

778


What happens if I remove static from main method?

791


Explain the difference between map and flatmap stream operation?

1059


explain copyonwritearraylist and when do we use copyonwritearraylist?

761


Is set thread safe java?

731


What is super constructor?

773


Define how objects are stored in java?

807


How do I get the | symbol on my keyboard?

809


can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread

773


What does string mean in java?

851


What is appletviewer?

822


What is passing value java?

750


Explain the importance of thread scheduler in java?

811