Sie sind auf Seite 1von 1

What is an abstraction?

Abstraction is a way of converting real world objects in terms of class. It’s a concept of defining
an idea in terms of classes or interface. For example creating a class Vehicle and injecting
properties into it.

public class Vehicle {


public String colour;
public String model;
}

What is Encapsulation?

The encapsulation is achieved by combining the methods and attribute into a class. The class
acts like a container encapsulating the properties. The users are exposed mainly public methods.
The idea behind is to hide how things work and just exposing the requests a user can do.

Polymorphism

Method Overloading and Method Overriding.

Static & Instance

Static: Memory is allocated only once in the program. Common for every object - there memory
location can be sharable by every object reference or same class. Static variable can be accessed
with class reference.

Instance: Memory is allocated whenever a new object is created. Specific to an object. Can be
accessed with object reference.

Abstract Class & Interface.


Abstract Classes can't be instantiated. Need to create Abstract class to create abstract Methods.
Abstract Methods can be implemented by Redefinition in child classes.

Interfaces are 100% Abstract. Methods of Interface can be implemented by Classes only.

Das könnte Ihnen auch gefallen