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

When throw keyword is used?

591


What is immutability in java?

606


What do you mean by buffering?

553


What is string in java?

562


In java, what is the difference between method overloading and method overriding?

581






What is javac used for?

514


What is an anonymous class in java?

544


Do you know why doesn't the java library use a randomized version of quicksort?

554


When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?

569


Write a function to print Fibonacci series and Tribonacci series?

759


Can we create constructor in abstract class ?

581


What does function identity () do?

517


What is the diffrence between inner class and nested class?

564


Outline the major features of java.

565


What is the use of conditional statement?

564