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
Is 0 true or is 1 true?
Is main a function?
Can java object be locked down for exclusive use by a given thread?
How do generics work?
Is null false in java?
What is ellipsis in java?
How list contains works in java?
Will the compiler creates a default constructor if I have a parameterized constructor in the class?
What are the different access modifiers available in java?
what is the purpose of using rmisecuritymanager in rmi?
What if constructor is protected in java?
Where to store local variables?
What is the purpose of using bufferedinputstream and bufferedoutputstream classes?
What is a qms manual?
Does string isempty check for null?