File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes re; MindQ test question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "re; MindQ test question" Watch "re; MindQ test question" New topic

re; MindQ test question

art mudick

Joined: Feb 15, 2004
Posts: 8
Here is a question from MindQ test
class Super
int methodOne( int a, long b ) throws IOException
{ // code that performs some calculations
float methodTwo( char a, int b )
{ // code that performs other calculations
public class Sub extends Super
Which of the following are legal method declarations to add to the class Sub? Assume that each method is
the only one being added.
a) public static void main( String args[] ){}
b) float methodTwo(){}
c) long methodOne( int c, long d ){}
d) int methodOne( int c, long d ) throws ArithmeticException{}
e) int methodOne( int c, long d ) throws FileNotFoundException{}
I chose answer a,b,d and e. Could someone tell me if it right.
Lucy C
Ranch Hand

Joined: Feb 09, 2000
Posts: 53
Answer e is not valid, as an overriding method like this can't throw any checked exceptions that aren't thrown by the method it overrides - and FileNotFoundException is a checked exception.
ArithmeticException is a runtime exception, so d is valid.
josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
e is valid becoz FileNotFoundException is a subclass of IOException .U can have the same Exception as in Overridden method or its subclass
Lucy C
Ranch Hand

Joined: Feb 09, 2000
Posts: 53
You're right - I didn't read the code properly. Better not do that in the exam...
Chuck Lan

Joined: Feb 17, 2000
Posts: 6
so a is okay, b is okay because it's method overloading. c is not okay because the overriding method has a different return type. d is okay because ArithmeticException is a runtime exception. e is okay because FileNotFoundException is a subclass of IOException.
I agree. Here's the link:
subject: re; MindQ test question
It's not a secret anymore!