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
What are latest features introduced with java 8?
What do you understand by the term wrapper classes?
Can anonymous class have constructor?
Can we use static class instead of singleton?
What is java basic concept?
What is map java?
Is it possible to use string in the switch case?
What is a blocking method in Java?
How is java hashmap implemented?
What is the major advantage of external iteration over internal iteration?
Give any two differences between C++ and java.
How many types of memory areas are allocated by jvm?
Does java support multiple inheritances?
Are functions objects in java?
Is array size fixed in java?