GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method overriding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method overriding" Watch "method overriding" New topic
Author

method overriding

akash azal
Ranch Hand

Joined: Jan 31, 2009
Posts: 70
The overriding method must NOT throw checked exceptions that are new
or broader than those declared by the overridden method.

what does this statement means .can anyone explains with example


We will keep things moving!!
Omar Al Kababji
Ranch Hand

Joined: Jan 13, 2009
Posts: 357
suppose that you have the following type of exceptions

Exception1 extends Exception
Exception2 extends Exception1
Exception3 extends Exception
RuntimeException1 extends RuntimeException

and that you have a method with the following signature:



here is what you can override and what you can't override



Omar Al Kababji - Electrical & Computer Engineer
[SCJP - 90% - Story] [SCWCD - 94% - Story] [SCBCD - 80% - Story] | My Blog
Paul Stat
Ranch Hand

Joined: Jan 20, 2009
Posts: 50
For example

akash azal
Ranch Hand

Joined: Jan 31, 2009
Posts: 70
3 runtimeexception 1 is not a child of exception1

then how it is ok

and to know this we have to know the exceptions and subexceptions by heart
Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
Runtime exception is not a checked Exception


be a well encapsulated person, don't expose your privates, unless you public void getWife()!
akash azal
Ranch Hand

Joined: Jan 31, 2009
Posts: 70
we have to know about exceptions and subexceptions by heart
Paul Stat
Ranch Hand

Joined: Jan 20, 2009
Posts: 50
You need to know the following for the exam

ArrayIndexOutOfBoundsException
ClassCastException
IllegalArgumentException
IllegalStateException
NullPointerException
NumberFormatException
AssertionError
ExceptionInInitializerError
StackOverflowError
NoClassDefFoundError
 
GeeCON Prague 2014
 
subject: method overriding