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
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 |
Answer / surendra
the overriding method can throw narrow exceptions than overridden exception
| Is This Answer Correct ? | 3 Yes | 0 No |
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 |
Answer / contessa
yes, you will be overriding to throw a different exception
| Is This Answer Correct ? | 0 Yes | 5 No |
What is DTD?
What are the different algorithms used for clustering?
What is RMI Registry?
6 Answers Siemens, United Software Solutions,
Suppose there are 3 combo box. SELECT COUNTRY SELECT STATE SELECT CITY if i select any country from country conutrylistbox values in the state will get automatically inserted with database values>> THEN on selection of state city will be inserted in city combo box If you can help then please Help me...
Explain the methods of Naming class, rebind( ) and lookup()?
Does Java pass arguments by value or reference?
What is the initial state, When a thread is created and started?
What are different types of layout managers in java.awt package?
how to make a index.jsp for running the site in internet and find an error for connection with weblogic server and java that give an error invalid object name.and how to maintain session.
What is local interface. How values will be passed?
Which Taglibraury you used in your project? plz send me ans....which we r using generally
Wt is the main difference between Java and Java J2EE and Advanced java?