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
Differentiate between run time error and syntax error.
How many inner classes can a class have?
Can we overload final method in java?
What is the biggest integer?
Does A Class Inherit The Constructors Of Its Superclass?
What are instance variables?
List some oops concepts in java?
Can anonymous class have constructor?
What is a default method?
What are peerless components in java programming?
What will be the output of round(3.7) and ceil(3.7)?
How do you reverse a string in java?
Why strings in java are called as immutable?
What is the meaning of I ++ in java?
How do generics work?