Welcome Guest | Sign in | Register
Exceptions - Discussion Page For Q.2627 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Exceptions > Questions and Answers

Q: class A{
void display() throws IOException,FileNotFoundException {
System.out.println(“class A”); }
}
class B extends A {
void display() throws IOException, FileNotFoundException,NullPointerException {
System.out.println(“class B”); }
}
class Test {
Public static void main(String args[]){
B b=new B();
b.display(); }
}
Output?
A. class A B. class B
C. class A, class B D. compile time error

Answer and Explanation

Answer:compile time error

Explanation:
In the above program class A is super class and it is throwing two exceptions. In class B which is child class of A must throw less number of exceptions compare to A. If child class throws more number of exceptions compare to super then the program will not compile successfully.
So d) is correct.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.