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 set security in applets?

1 Answers   IBM,


can a static method be overridden

12 Answers   SolutionNET,


What are the ways to define classes that can be run as threads?

1 Answers   KPIT,


What are JTA/JTS and how they used by client?

0 Answers  


Why is string immutable in java?

0 Answers  






What restrictions are placed on the values of each case of a switch statement?

0 Answers  


a US company has filed my H1B visa ,, and i got selected in random number process.I wanna ask Could they ask regarding my languages(java,c++) or there will b just general questions?? And wat kind of questions will they ask in embassy interview??

2 Answers  


diff between jsp include directive and jsp action include?

2 Answers   SolutionNET,


we use MainFrame and using os390 for operating system with DB2 data base in IRAN and interest programing with java and use webspere for world wide,please help me where i should start?

0 Answers   IBM,


1) which method of the RequestDispatcher cannot be called once the output is sent to the client? a. forward b. include c. both a&b 2) which interface should an object implement to get notified of changes to the list of active sessions in a web application? a. HttpSessionListener b. HttpSessionActivationListener c. HttpSessionAttributeLIstener 3) A user can select multiple locations from a list box on an HTML form, which of the following methods can be used to retrieve all the selected location? a. getParameter() b. getParameterValues() c. getParamValues() 4) which of the following methods should be used to send character text to the client? a. ServletResponse.getWriter() b. ServletResponse.getOutputStream() c. ServletResponse.getOut() 5) which implicit object is always available in a JSP page? a. exception b. session c. out 6) which inclusion mechanism doesn't include the source of the page, rather the output of the page. a. include directive b. jsp:include action c. Bothe a& b 7) which attribute of the page controls whether a page participates in session or not? a. session-allowed b. session c. isSession

1 Answers  


How has the sandbox changed with Java 2?

2 Answers  


How can a dead thread be restarted?

1 Answers   IBM, Wipro,


Categories