In method overloading ,if i change the return type to Long
instead of INT,is the program execute
Answer Posted / sitaram
class OverloadDemo {
int test(int x) {
return x*x;
}
int test(long a) {
long l = a*a*a;
return l;
}
double test(double a) {
return a*a;
}
}
public class Over extends OverloadDemo{
public static void main(String[] args) {
OverloadDemo od = new OverloadDemo();
int a = od.test(12.456); //error:Can't convert from
double to int.
}
}
Program not compiled . because Can't convert from double to int.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What is the difference between jvm and jre? What is an interface?
What does s mean in regex?
How to do a true java ping from windows?
Explain the importance of finally block in java?
Describe different states of a thread.
Explain the protected field modifier?
What is the difference between inner class and nested class?
What was java originally called?
Which collection allows duplicate values in java?
Differences between traditional programming language and object oriented programming language?
What is the difference between array and array list in java?
How many types of design patterns are there?
Why do we need wrapper classes?
What is the purpose of javac exe?
What is a null check?