I hope I'm in the right forum, I apologize in advance if this questions should belong in the "intermediate" group, but I don't think this is more of a beginners questions. Well here goes...I took this exam with the following question:
Which of the following methods can be legally inserted in place of the comment //Method Here?
class Base
{
public void amethod( int i )
{
}
}
public class Scope extends Base
{
public static void main(
String argv[] )
{
//Method Here
}
}
1. void amethod( int i ) throws Exception()
2. void amethod( long i ) throws Exception()
3. void amethod( long i ){}
4. public void amethod( int i ) throws Exception
I chose answer #4 since "public" is less or equals to restrictive (in this case, equal to ) to the method that is being overriden, since the others would have a "default/package" modifier. Supposedly, the answer is #2 and #3. Can someone please explain why #2 and #3 would be correct?
Explanation is appreciated!