Académique Documents
Professionnel Documents
Culture Documents
Protected member
A superclass sprotectedmembers can be accessed by members of that superclass, by members of its subclasses and by members of other classes in the same pac$age,protectedmembers also have pac$age access. Allpublicandprotectedsuperclass members retain their original access modifier when they become members of the subclass
Poloymor !ism
/hen a superclass variable contains areference to a subclass object, and that reference is used to call a method, the subclass version of the method is called
5ou must deal with chec$ed exceptions. This results in more robust code than would be created if you were able to simply ignore the exceptions. &ommon 8rogramming "rror 00.2 A compilation error occurs if a method explicitly attempts to throw a chec$ed exception *or calls another method that throws a chec$ed exception+ and that exception is not listed in that method sthrowsclause. &ommon 8rogramming "rror 00.4 If a subclass method overrides a superclass method, it s an error for the subclass method to list more exceptions in itsthrowsclause than the overridden superclass method does. 3owever, a subclass sthrowsclause can contain a subset of a superclass sthrowslist. 6oftware "ngineering 7bservation 00.9 If your method calls other methods that throw chec$ed exceptions, those exceptions must be caught or declared in your method. If an exception can be handled meaningfully in a method, the method should catch the exception rather than declare it.
#nter$ace
All methods declared in an interface are implicitlypublic abstractmethods, and all fields are implicitlypublic, staticandfinal A class that does not implement all the methods of the interface is an abstractclass and must be declared abstract
&ommon 8rogramming "rror 00.2 A compilation error occurs if a method explicitly attempts to throw a chec$ed exception *or calls another method that throws a chec$ed exception+ and that exception is not listed in that method sthrowsclause. &ommon 8rogramming "rror 00.4 If a subclass method overrides a superclass method, it s an error for the subclass method to list more exceptions in itsthrowsclause than the overridden superclass method does. 3owever, a subclass sthrowsclause can contain a subset of a superclass sthrowslist. 6oftware "ngineering 7bservation 00.9 If your method calls other methods that throw chec$ed exceptions, those exceptions must be caught or declared in your method. If an exception can be handled meaningfully in a method, the method should catch the exception rather than declare it.