Will it be called overriding if I do not change the
parameters or return type, instead throw a different
exception in the method signature.

Answers were Sorted based on User's Feedback



Will it be called overriding if I do not change the parameters or return type, instead throw a dif..

Answer / prakash

An Overridden method can throw lesser exceptions or no
exception and any new Runtime exceptions

An overridden method can't throw any new checked exception
or broader exceptions than its base class method.

Is This Answer Correct ?    6 Yes 0 No

Will it be called overriding if I do not change the parameters or return type, instead throw a dif..

Answer / surendra

the overriding method can throw narrow exceptions than overridden exception

Is This Answer Correct ?    3 Yes 0 No

Will it be called overriding if I do not change the parameters or return type, instead throw a dif..

Answer / siva

public class MyOverriding {
int add(int a, int b)throws Exception{ //TRUE
return a+b;
}
}
class SubClass extends MyOverriding {
int add(int a, int b)throws NullPointerException{
return a+b;
}
}

//BELOW CODE IS GETTING COMPILER ERROR
public class MyOverriding {
int add(int a, int b)throws NullPointerException{
return a+b;
}
}
class SubClass extends MyOverriding {
int add(int a, int b)throws Exception{
return a+b;
}
}

Is This Answer Correct ?    2 Yes 0 No

Will it be called overriding if I do not change the parameters or return type, instead throw a dif..

Answer / contessa

yes, you will be overriding to throw a different exception

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More Advanced Java Interview Questions

How do you maintain a stateful session object across the session

2 Answers   HCL,


Is a class a subclass of itself?

0 Answers  


what's the main difference between unix os and linux os?

2 Answers   TCS,


In HashTable I am storing null value..then what is the error it will show

2 Answers   GM General Motors,


What state a thread enters, When it blocks on I/O?

2 Answers  






How do you download stubs from a Remote place?

1 Answers  


What is servlet preinitialization?

3 Answers   iFlex,


Which javutil classes and interfaces support event handling?

0 Answers  


What is there in browser that it supports web based applications of java or any other PL?

2 Answers  


What are the diff types of exception?

0 Answers  


whats is mean by filter?

1 Answers   SolutionNET,


What are the high-level thread states?

1 Answers  


Categories