Abstraction in Java

An abstract class is a class that is declared using the abstract keyword. An abstract class cannot be instantiated. It can be used only as a super-class for those classes that extend the abstract class. The default functionality of the class still exists, with its fields, methods and constructors being accessed in the same way […]

Read More Abstraction in Java

Inheritance in Java

The most fundamental element of Java is the class. A class represents an entity and also, defines and implements its functionality. In Java, classes can be derived from other classes, in order to create more complex relationships. A class that is derived from another class is called subclass and inherits all fields and methods of its superclass. In Java, only […]

Read More Inheritance in Java

Polymorphism in Java

Polymorphism is the ability of an object to take on many forms. In Java, polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. In short, to see how polymorphism works we have created the above classes that extend the same class and override […]

Read More Polymorphism in Java

Encapsulation in Java

Encapsulation is the mechanism for restricting access to an object’s components. It aims for high maintenance and handling of the application’s code. Also, the encapsulation mechanism protects the members of a class from external access, in order to be protected against unauthorized access. Encapsulation can be described as a protective barrier that prevents the code […]

Read More Encapsulation in Java