JAVA – Abstract Classes and Methods

The definition of a class should not be instantiated since it only represents the abstract concept. For example, the instance of pet can not be seen. What you can see are the instances of cat, dog, pig or horse. The instance of pet can not be seen and does not make sense.

Abstract Classes

As with object-oriented programming, declaring abstract concepts might be desired, but there is no possibility that you can create an instance of same. For example, the abstract concept of numbers is represented by Number class available with the java.lang package. The Number class serves as a model for numbers used in programs but is impossible to create the generic object.

The Number class is parent class of number of other number classes like Integer and double which implements specific types of numbers. The abstracted class represented by the number class, which implements abstract concepts. Abstract classes can be subclassed but it cannot have instance of it.

Continue reading JAVA – Abstract Classes and Methods

JAVA – Static Member classes

The static member class is similar to any other class, but this type of class is nested within another simple class. The static member can be used both by the external classes and the class in which it is defined. The static member class can be used by hierarchical name using name of containing class as prefix.

Some of the features of the static member class are:

  • The static member class is always defined with static modifier. This way static member class becomes equivalent to all other class members which are declared with static modifier.
  • A static member class can use access control modifiers, without any alteration in the meaning of these modifiers.
  • The static member class can access all the static members of containing class (private member as well). ses.
  • The static member class can not be associated instances of the containing class.