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

What are the purpose of introspection?

676


Do I have to use jsps with my application?

579


What is the difference between the string and stringbuffer classes?

541


How are the elements of a cardlayout organized?

594


What is ioc concept?

687






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

581


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

635


What is a class loader? What are the different class loaders used by jvm?

581


Why are component architectures useful?

570


which book is better for jdbc ,servlets and jsp

1644


What is the relationship between an event-listener interface and an event-adapter class?

552


What are the different class loaders used by jvm?

592


what are getters and setters in Java with examples?

1282


What do you need to set-up a cluster with jboss?

573


How primary key is implemented in Oracle?

1914