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
What are the purpose of introspection?
Do I have to use jsps with my application?
What is the difference between the string and stringbuffer classes?
How are the elements of a cardlayout organized?
What is ioc concept?
How are commas used in the intialization and iteration parts of a for statement?
Is the ternary operator written x : y ? Z or x ? Y : z ?
What is a class loader? What are the different class loaders used by jvm?
Why are component architectures useful?
which book is better for jdbc ,servlets and jsp
What is the relationship between an event-listener interface and an event-adapter class?
What are the different class loaders used by jvm?
what are getters and setters in Java with examples?
What do you need to set-up a cluster with jboss?
How primary key is implemented in Oracle?