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
Why are generics used?
what is object-oriented programming in java?
Why are the destructors for base class and derived class called in reverse order when the program exits
How many bytes is string in java?
What is the final blank variable?
Why hashset is used in java?
How many types of methods are there?
How do you implement tree mirroring in java?
What is the difference between conversation & casting?
Why is singleton not thread safe?
Is space a character in java?
Mention some features of java?
What is a arraylist in java?
What is illegal identifier in java?
what is recursion in java