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 difference between abstract class and interface1? What is an interface?
Why we used break and continue statement in java?
What is the difference between state-based unit testing and interaction-based unit testing?
What is the major difference between linkedlist and arraylist?
What are features of java?
Explain how can you debug the Java code?
Is set ordered in java?
Difference between java and javascript
Write a program to find the whether a number is an Armstrong number or not?
how would you implement a thread pool? : Java thread
What is difference between length and length() method in java ?
Which variable is the independent variable?
v-model life cycle
What are the features in java?
can rmi and corba based applications interact ?