what is overloading in java?
Answer Posted / saurabh
it is a example of overloading:-
class Overload {
void test(int a) {
System.out.println("a: " + a);
}
void test(int a, int b) {
System.out.println("a and b: " + a + "," + b);
}
double test(double a) {
System.out.println("double a: " + a);
return a*a;
}
}
class MethodOverloading {
public static void main(String args[]) {
Overload overload = new Overload();
double result;
overload.test(10);
overload.test(10, 20);
result = overload.test(5.5);
System.out.println("Result : " + result);
}
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?
What is the purpose of the system class in java programming?
What is rmi and steps involved in developing an rmi object?
What are different type of exceptions in java?
What does java ide mean?
What is an example of a constant variable?
Is constructor inherited?
In a container there are 5 components. I want to display all the component names, how will you do that?
what is daemon thread and which method is used to create the daemon thread? : Java thread
What are the advantages of exception handling?
When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?
Is multiple inheritance supported by java?
Can a constructor call another constructor?
What are the different tags provided in jstl?
What is OOP's Terms with explanation?