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
How many types of exception can occur in a java program?
Can a static member function access member variable of an object?
List some important features of java 10 release?
Give a practical example of singleton class usage?
What is instanceof keyword?
Why set do not allow duplicates in java?
is there a separate stack for each thread in java? : Java thread
What is an abstract class and what is it’s purpose?
Explain the selection sort algorithm?
How many types of classes are there in java?
What is jrmp?
What is string [] args?
Can we override the static methods?
How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?
What is java command?