SCJP Study Notes


Overloading, Overriding, Runtime Type and Object Orientation

  • A static method may hide another static method. A static method (in a subclass) can NOT hide a non static method (in superclass).
  • It does not make sense to declare a static method abstract since static methods can not be overridden.
  • Methods with private modifier can not be overridden as they are not visible outside the class.
  • When overriding a method, the overriding method must return the same as the original method, and must have the same signature (parameter list) as the original.
  • The return type does not contribute towards distinguishing between one method and another.
  • Overloaded methods do not have any restrictions on what exceptions can be thrown.
  • Methods may not be overridden to be more private.
  • Constructors never return a value. If you do specify a return value, the JVM will interpret your intended constructor as a method.
  • All methods in an interface are automatically public. Hovewer while implementing the interface you must declare the method as public.
  • A class that contains an abstract method must be declared abstract itself, but may contain non abstract methods.
  • Encapsulation involves hiding data of a class and allowing access only through a public interface.
  • A final method cannot be ovverriden in a sub class, but apart from that it does not cause any other restrictions.
  • A member class is an inner class whose declaration is directly enclosed in another class or interface declaration.
  • Member inner classes can be public, protected,private or default.
  • Member inner classes has access to member variables of outer.
  • Member inner classes can be instantiated on the instance of the outer.
  • Static nested classes has access to only static members of outer.
  • Static nested classes may be instantiated / accessed without the instance of outer.
  • Local class defined in a method has access to final method variables and parameters and also to the outer class' member variables.
  • An anonymous inner class is never abstract. (definition, construction and usage at the same time)
  • An anonymous inner class is always implicitly final and it is never static.
  • Anonymous inner classes can extend a class or implement an interface but NOT both at the same time.
  • An abstract class can have final methods.
  • An abstact class can have static methods.
  • A class without abstract methods can still be declared abstract.
  • Encapsulation enhances the maintainability of the code.
  • A tightly encapsulated class allows access to data only through accessor and mutator methods.
  • A tightly encapsulated class might have mutator methods that validate data before it is loaded into the internal data model.
  • An abstract method can be overridden by an abstract method. An instance method that is not abstract can be overridden by an abstract method.

contents | previous | next