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

What is the indent key?

594


You're given a Boolean 2D matrix, can you find the number of islands?

606


Explain runtime exceptions?

753


What is difference between Heap and Stack Memory?

547


Why is stringbuffer not immutable?

576






State differences between C and Java?

671


Can a class have multiple superclasses?

576


Why java is object oriented?

592


Tell some latest versions in JAVA related areas?

566


What is the difference between sop and work instruction?

490


Can a class be a super class and a sub-class at the same time? Give example.

818


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

548


Why is a singleton bad?

566


What are "methods" and "fields"?

585


How does singleton class work?

537