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

Is 0 true or is 1 true?

514


Is main a function?

510


Can java object be locked down for exclusive use by a given thread?

578


How do generics work?

514


Is null false in java?

702






What is ellipsis in java?

570


How list contains works in java?

550


Will the compiler creates a default constructor if I have a parameterized constructor in the class?

579


What are the different access modifiers available in java?

557


what is the purpose of using rmisecuritymanager in rmi?

560


What if constructor is protected in java?

556


Where to store local variables?

579


What is the purpose of using bufferedinputstream and bufferedoutputstream classes?

545


What is a qms manual?

537


Does string isempty check for null?

556