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 same as procedures?
When should we create our own custom exception classes?
What is array command?
How to use arraylist in java netbeans?
Explain treeset?
Explain about interrupt() method of thread class ?
What is meant by anonymous class?
Can we use both this () and super () in a constructor?
Explain the importance of join() method in thread class?
What is method reference in java?
Difference between collection, collection and collections in java?
Can we override constructor?
What is the equal sign?
Why collection doesn’t extend cloneable and serializable interfaces?
How do you create immutable object in java?