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
Can we have static methods in an interface?
What is meant by string is immutable?
what is inner class in java?
Are floats faster than doubles?
What is style and indentation?
In case of inheritance what is the execution order of constructor and destructor?
Can we have try without catch block?
what is the messsage u r going to get from an objectoriented programing?
What is static and final keyword in java?
How objects of a class are created if no constructor is defined in the class?
What is garbage collector?
What does @param args mean in java?
How many types of voids are there?
Why does java not support pointers?
when should you use stringbuilder class in a program?