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

Which Taglibraury you used in your project? plz send me ans....which we r using generally

2 Answers  


What does module-relative mean?

0 Answers  


Is the ternary operator written x : y ? Z or x ? Y : z ?

0 Answers  


What is chat area? Explain.

0 Answers  


What are the steps to write p-to-p model application?

0 Answers  


Which class is the immediate superclass of the menucomponent class?

0 Answers  


Tell me about Firewalls in RMI?

0 Answers  


Describe, in general, how java's garbage collector works?

0 Answers  


How u validate date in DD/MM/YY format. and how u validate money in ur jsp

3 Answers   Ashok Leyland, Satyam, Tech Mahindra, Tomax,


How to synchronize jsp page?

1 Answers   Infotech, TCS,


What method is invoked to cause an object to begin executing as a separate thread?

0 Answers  


Why do I get a duplicate name error when loading a jar file?

0 Answers  


Categories