Handling exception in overridden class
Code :
import java.io.*;
class A
{
public void display()
{
System.out.println("SuperClass");
}
}
public class B extends A
{
@Override
public void display() throws IOException
{
System.out.println("SubClass");
}
}
Here, A is base class and B is derived class.
Now if method display() in class B throws IOException, it gives compile error.
It says, overridden method does not throw java.io.IOException. What does that mean?
But if it throws any other exception like ArithmeticException or NullPointerException, it works fine.
So, what is the problem??
Plzzz help.
Re: Handling exception in overridden class
Quote:
overridden method does not throw java.io.IOException.
You are trying to change the definition of the method.
You have left off part of the error message. Please post the full text of the error message.
Re: Handling exception in overridden class
throws IOException Did U Use In Second Method What U R Doing There I Didnt get You But If U R Throwing A Exception ,Exception Will Never Create Here N U R Throwing The IoException Just Try With Out That plz Give The Description What u Want To Do
Re: Handling exception in overridden class
Quote:
Originally Posted by
jitu.ideas2it
throws IOException Did U Use In Second Method What U R Doing There I Didnt get You But If U R Throwing A Exception ,Exception Will Never Create Here N U R Throwing The IoException Just Try With Out That plz Give The Description What u Want To Do
Please write with proper grammar. Your post is virtually unreadable...'U' and 'plz' are not words