| Author |
combination of access & non-access modifiers for a class
|
siva prakash
Ranch Hand
Joined: Aug 24, 2004
Posts: 80
|
|
Hi All, I am reading K&B book, page :15, and tried following combinations and getting compilation error, Can any one explain me what could be logic for it. 1) private & protected with "final" modifier 2) private & protected with "strictfp" modifier 3) private & protected with "abstract" modifier , i can understand the combination of private & abstract showing compilation error. Thanks inadvance, Prakash.
|
 |
Antonio Tercero
Ranch Hand
Joined: Jun 05, 2008
Posts: 110
|
|
It depends: final modifier means that you can't change the value of a variable member , and with methods it means that you can't override it so all access modifiers(private , protected, public ..) can be used with final. abstract modifier means that the method is not implemented. You can declare an abstract method in an abstract class or an interface. In an abstract class, you can only apply protected, public or "Default" access modifers: you CAN'T apply private modifier because the first non-abstract method that extends the abstract class doesn't inherits private methods. Example: In an interface, all methods declared are by default public and abstract, so you can only use public with abstract. Finally, a method can't be final and abstract at the same time final -> can't override the method abstract -> you must override the method
|
SCJP 5, SCWCD 5
|
 |
 |
|
|
subject: combination of access & non-access modifiers for a class
|
|
|