SCJP Study Notes


Declarations and Access Control

  • The only access modifier permitted to non-nested class is public; there is no such thing as a protected or private top-level class.
  • Only variables and methods may be declared protected.
  • Static methods are not allowed to use the non-static features of their class.
  • The native modifier can refer only to methods. The library that contains the native code ought to be loaded and available to the JVM.
  • The transient modifier apply only to variables.
  • The volatile modifier applies only to variables and is not common in use. They are interest of in multiprocessor environments.
  • Constructors can have public, protected and private (or none) modifiers.
  • An abstract class must not contain at least one abstract method. When a class has at least one abstract method, then it must be declared abstract.
  • Initilializer blocks are executed in the order of declaration.
  • An interface that is declared within the body of a class or interface is known as a nested interface.
  • A class declaration can be a member of an interface.
  • No matter where they declared, static variables will be intitialized before non-static variables.
  • All interfaces are implicitly abstract. The explicit application of the abstract modifier to an interface declaration is redundant and is strongly discouraged.
  • If the declaration of a final variable does not include an initializer then the variable is called a blank final. All blank, final, static variables must be
    assigned in a static initializer. All blank final non-static variables must be assigned by the end of the instance construction process.
  • A variable that is local to a method can not be part of the persistent state of an object, so the transient modifier is not useful and not legal.
  • A variable that is local to a method can not be accessed from outside of the class, so the access modifiers are not useful and not legal.
  • Local variables can not be shared between threads, so the volatile modifier is not useful and not legal.
  • The keywords, super and this can not be used in the body of a static method.

contents | previous | next