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
What is the indent key?
You're given a Boolean 2D matrix, can you find the number of islands?
Explain runtime exceptions?
What is difference between Heap and Stack Memory?
Why is stringbuffer not immutable?
State differences between C and Java?
Can a class have multiple superclasses?
Why java is object oriented?
Tell some latest versions in JAVA related areas?
What is the difference between sop and work instruction?
Can a class be a super class and a sub-class at the same time? Give example.
When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?
Why is a singleton bad?
What are "methods" and "fields"?
How does singleton class work?