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
Can I use multiple html form elements with the same name?
How can I avoid validating a form before data is entered?
What value does read() return when it has reached the end of a file?
How would you reatach detached objects to a session when the same object has already been loaded into the session?
What is a session? Can you share a session object between different theads?
Explain about local interfaces.
Name three subclasses of the component class?
Is the ternary operator written x : y ? Z or x ? Y : z ?
Is “abc” a primitive value?
What is the difference between system.out ,system.err and system.in?
What is the difference between the string and stringbuffer classes?
What is glasgow?
What are the different types of exception?
what is handle?
Can you give me a simple example of using the requiredif validator rule?