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
State the difference between creating string as new () and literal.
What is ‘is-a ‘ relationship in java?
What is the primitive type byte?
how to deploy apache tomcat server to weblogic server in java
What is the purpose of garbage collection in java, and when is it used?
What are the object and class classes used for?
Differences between C and Java?
When throws keyword is used?
What is the use of join method?
What is map and hashmap in java?
Explain the difference between string, stringbuffer and stringbuilder in java?
How can you share data between two thread in Java?
Can we nested try statements in java?
What is an interoperable application in java ?
Explain the importance of join() method in thread class?