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
Which collection allows duplicate values in java?
What are the steps involved to create a bean?
What is an example of a boolean?
What isan abstract class and when do you use it?
How do you classify Dialog Box?
What are controls and their different types in awt?
Difference between concurrent hashmap and hashtable and collections
Is overriding possible in java?
How do you read a char in java?
What is the format specifier?
Write a program to print count of empty strings in java 8?
Can there be an abstract method without an abstract class?
What classes of exceptions may be thrown by a throw statement?
What are the advantages of exception handling?
What is a variable simple definition?