Author Topic:   Overridding
Alkesh Nandanwar
ranch hand
posted March 21, 2000 11:57 AM             
Hi Again
code:

import java.io.*;
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 marked correct answers as a) b) d) e) but d) is not given as correct answer.
I my opinion there is no restricition on AritmaticException() when overridding in sub classess.
Am I missing something
ALkesh

Jane Rozen
ranch hand
posted March 21, 2000 01:02 PM             
You're right.
There have been discussions about it at this forum, one message was posted by Tony,called "Good(IMO) Practice Question" - search for it .(I don't know how to include links in replies).

maha anna
bartender
posted March 21, 2000 08:09 PM             
The answers given is wrong. There is no restriction for an overriding method in throwing a RuntimeException/Error or any subclass of RuntimeException/Error . The compiler doesn't care about it as long as the other overriding rules are followed .
And your answers are all correct.
regds
maha anna

Alkesh Nandanwar
ranch hand
posted March 21, 2000 09:55 PM             
hi Maha anna,
So can you please put the information regarding this question in the Mock Exam Errata Forum because I found this question in MindQ mack exam
ALkesh

Jim Yingst
sheriff
posted March 21, 2000 10:17 PM             
I'll move it now. Also, note that actually A is the only one really correct because all the others are declared to return int, long, or float - but none have return statements. So it's a pretty crappy question all around.

|