File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Overload, Override & more specific Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Overload, Override & more specific" Watch "Overload, Override & more specific" New topic
Author

Overload, Override & more specific

Alfred Kemety
Ranch Hand

Joined: Aug 14, 2002
Posts: 279
What will the following code do on compiling and running?

A- prints 5
B- prints 10
C- Compile Error because of ambiguity
D- Compile Error at declaration of aMethod in class Test
More important than what is why?


Alfred Raouf - Egypt - SCJP 1.4<br />Kemety.equals(Egyptian) // returns true
Aniruddha Mukhopadhyay
Ranch Hand

Joined: Nov 15, 2000
Posts: 59
Answer obviously is B (will print 10). There is no case of method overriding here as methods have different argument type. As the argument is of type int, method:
public long aMethod(int x) {
return 5 * x;
}
will get called and output on screen will be 10.


Aniruddha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overload, Override & more specific
 
Similar Threads
jtips mock 1 Q33
Jtips mock exam
try catch finally question
return statment in try/catch clause
abstract class instantiation