Tags

What is OOP?
is a programming paradigm using “objects” – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.

What is class?
-A class is the blueprint that describe the details of an object.

What is object?
-Object is an instance of a class.

What is inheritance?
-Where one class can inherit properties of another class thus helping in reuse of code.
-Ability of a new class to be created, from an existing class by extending it.

What is polymorphism?
The ability to substitute one class for another.
In OOP the polymorphisms is achieved by using many different techniques named method overloading, operator overloading and method overriding.

What is the difference between an Interface and an Abstract class?
There are quite a big difference between an interface and an abstract class, even though both look similar.
        Interface definition begins with a keyword interface so it is of type interface
        Abstract classes are declared with the abstract keyword so it is of type class

        Interface has no implementation, but they have to be implemented.
        Abstract class’s methods can have implementations and they have to be extended.

        Interfaces can only have method declaration (implicitly public and abstract) and fields (implicitly public static)
        Abstract class’s methods can’t have implementation only when declared abstract.

        Interface can inherit more than one interfaces
        Abstract class can implement more than one interfaces, but can inherit only one class

        Abstract class must override all abstract method and may override virtual methods
        Interface can be used when the implementation is changing
        Abstract class can be used to provide some default behavior for a base class.
        Interface makes implementation interchangeable
        Interface increase security by hiding the implementation

        Abstract class can be used when implementing framework
        Abstract classes are an excellent way to create planned inheritance hierarchies and also to use as non-leaf classes in class hierarchies.

Advertisements