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
Should a main method be compulsorily declared in all java classes?
Difference between string s= new string (); and string s = "abv";?
Explain the concept of hashtables?
How do you convert an int to a double in java?
How to reverse string in java?
What does you mean in math?
Can we pass a primitive type by reference in java? How
List out five keywords related to exception handling ?
What is the difference between quicksort & mergesort? When should they be used? What is their running time?
What is the latest version of java?
I want to persist data of objects for later use. What is the best approach to do so?
How do listeners work?
What is contractor means and methods?
What is udp in java?
What is a local class in java?