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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is actionform a base class rather than an interface?

578


why static class in java

1284


What are the pros and cons of detached objects?

555


How would you detect a keypress in a jcombobox?

684


Which textcomponent method is used to set a textcomponent to the read-only state?

643






What is a policy?

1782


Explain the different types of memory used by jvm?

618


Which containers use a border layout as their default layout?

618


Why use a datasource when you can directly specify a connection details?

540


How are commas used in the intialization and iteration parts of a for statement?

593


Which class is the immediate superclass of the menucomponent class?

645


How would you create a button with rounded edges?

566


Can we sent objects using Sockets?

659


whats is mean by connectionpooling

1574


What is the difference between session and entity beans?

587