In method overloading ,if i change the return type to Long
instead of INT,is the program execute

Answer Posted / umanath

Write a following program:

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;
}

}

Compile that program:

C:\>javac OverloadDemo.java
OverloadDemo.java:9: possible loss of precision
found : long
required: int
return l;

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we declare main () method as non static?

524


What is meant by collection in java?

560


Can java inner class be static?

562


Explain abstract class in java?

560


What is a singleton in genetics?

568






Explain static nested classes ?

599


What is a finally block?

568


How to retrieve data from database in java using arraylist?

532


What is printwriter in java?

522


What is the meaning of nullable?

580


Can a constructor have different name than a class name in java?

599


What are different types of classloaders?

591


How many types of operators are there?

529


What is nested interface?

525


What is meant by the value of a variable?

462