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


Please Help Members By Posting Answers For Below Questions

Why are generics used?

522


what is object-oriented programming in java?

589


Why are the destructors for base class and derived class called in reverse order when the program exits

1711


How many bytes is string in java?

611


What is the final blank variable?

592






Why hashset is used in java?

538


How many types of methods are there?

550


How do you implement tree mirroring in java?

597


What is the difference between conversation & casting?

582


Why is singleton not thread safe?

654


Is space a character in java?

516


Mention some features of java?

542


What is a arraylist in java?

562


What is illegal identifier in java?

538


what is recursion in java

601