Principals of Java Programming

The basic three principles of JAVA are inheritance, polymorphism and encapsulation. All the concepts of JAVA are based on classes and its objects. An object is a real-world entity that has some attributes or properties. Class is a prototype, blueprint or template on the basis of which objects are created. An object cannot exist without a class.

“Inheritance in object-oriented system means defining one class in terms of another. The new class defined is known as the child class or subclass or derived class. The class in terms of which the new class has been defined is known as the parent class or super class or base class. Each subclass inherits state and behavior from the super class. However, subclasses are not limited to the state and behaviors provided to them by their super class. Subclasses can add attributes and methods to the ones they inherit from the super class. Subclasses can also override inherited methods and provide specialized implementations for those methods.” (A. Rajesh, 2006)

In the OOP concept in Java inheritance can be divided into major 4 types. Such as

  1. Single level single inheritance: – In single level single inheritance there will be a one child class for one parent class.
  2. Single level multi inheritance: – In single level multi inheritance there will be more than one child class for the parent class.
  3. Multi-level single inheritance: – In multi-level single inheritance there can be one child class for every parent class in different levels.
  4. Multi-level multi inheritance: – In multi-level multi inheritance there can be more than one child class for every parent class in different levels.

Characteristics of inheritance

  1. Will inherit the sub class from the super class or child class from the parent class.
  2. Sub class can have the common attributes and methods of the super class.
  3. Can have different levels of inheritance.
  4. Sub classes will access the super class according to the access modifier which was set to it.
  5. This will form the generalization and specialization in common state and behaviors.

Purpose of using inheritance

  1. Used to create super class and sub classes into the program.
  2. It will allow the programmer to reuse the code from the base class.
  3. Easy to make changes to the global classes by changing the base class.

Example of inheritance

Forming of sub classes from super class is considered as the inheritance. Here the super class and the sub class will have the common attributes and also can have the unique attributes. When taking the persons as the super class the person can be divided into students and employees which can be derived from the person class. Here the both student and employee will have common states of the human being and unique states as student ID and employee ID and also the common and unique behaviors.


“It is a feature, which lets us create functions with same name but different arguments, which will perform differently. That is function with same name, functioning in different way.”  (, 2017)

Characteristics of polymorphism

  1. The program will have the same method names within it.
  2. Different types of parameters can be passed within the methods.
  3. It will have different method signatures within the program.
  4. This will form the method overloading mechanism within the system.

Purpose of using polymorphism

  1. Used to create method overloading function in the system.
  2. Used to create the methods with same method name by using the different method signature.
  3. Used to make the parameter passing concept into the program.

Example of polymorphism

Having same method name in a system is considered as polymorphism and it will be called as the method over loading. When taking the dog as the class and the dog will make sound woof in normal condition and it will make sound whimper when injured the polymorphism concept can be used as follows.


“Encapsulation is the process of binding both attributes and methods together within a class. Through encapsulation, the internal details of a class can be hidden from outside. The class has methods that provide user interfaces by which the services provided by the class may be used.” (, 2017)

Characteristics of encapsulation

  1. It will hide the internal functions of the system from the users.
  2. The user will feel the outside view of the system and can’t find out the internal mechanism of the program.
  3. Can be the blue print of the system.
  4. It will reduce the complexity of the program to the users.
  5. It will be worked as like as the capsule tablet in programming.
  6. Used to protect the coding of the system from the external users.

Purpose of using encapsulation

  1. Used to hide the codes from the users.
  2. Used to reduce the complexity of the program.
  3. It will only display the outer functions of the system to the users.
  4. It will be worked as the blue print of the devices.

Example of encapsulation

When taking the same example car and the ATM machine the hiding of the internal function is considered as encapsulation and the outer look for the users will be considered as abstraction.

Inheritance, polymorphism and encapsulation are the key principles of JAVA that are the foundation of the language. There are some other principles such as abstraction, data hiding that are less important. JAVA revolves mainly around these three basic principles.


“Abstraction is a process of exposing essential feature of an entity while hiding other irrelevant detail.” (Navneet Sinha, 2016)

Characteristics of abstraction

  1. It can be concluded as the different view sight of different users for a same thing.
  2. This will hide the unwanted data to the users according to their user types.
  3. This will be used to assign different user accounts in a program.
  4. It will only show the necessary features to the users.

Purpose of using abstraction

  1. It will be used to set the access modifier to the system.
  2. It will be used to allocate different user accounts to the system.
  3. Used to hide the unwanted parts from the users.
  4. Used to reduce the complexity of the system for the users.

Example for abstraction

In real life example abstraction can be done to hide the unwanted details to the users. When taking the same car as the example only the users know how to ride it and its external features and they didn’t know how it is function. When taking the ATM machine as the another example the users only know it can be used to withdraw, deposit money and to receive the receipt and they didn’t know how it is function.

Leave a Reply

Your email address will not be published. Required fields are marked *