Thursday, October 23, 2008

Other Modifiers—Members (Objective 1.3)

final methods cannot be overridden in a subclass.
abstract methods are declared, with a signature, a return type, and an optional throws clause, but are not implemented.
abstract methods end in a semicolon—no curly braces.
Three ways to spot a non-abstract method:
  1. The method is not marked abstract.
  2. The method has curly braces.
  3. The method has code between the curly braces.
The first nonabstract (concrete) class to extend an abstract class must implement all of the abstract class' abstract methods.
The synchronized modifier applies only to methods and code blocks.
synchronized methods can have any access control and can also be marked final.

abstract methods must be implemented by a subclass, so they must be inheritable. For that reason:
  1. abstract methods cannot be private.
  2. abstract methods cannot be final.
  3. The native modifier applies only to methods.
  4. The strictfp modifier applies only to classes and methods.

No comments: