Top 10 OOPs Interview Questions For 2022

 




OOPs Interview Questions

Q1) What is Object Oriented Programming?
Object-Oriented Programming(OOPs) is a type of programming that is based on objects rather than just functions and procedures. Individual objects are grouped into classes. OOPs implements real-world entities like inheritance, polymorphism, hiding, etc into programming. It also allows binding data and code together.

Q2) What is the difference between OOP and SOP?

Object-Oriented Programming Structural Programming
Object-Oriented Programming is a type of programming which is based on objects rather than just functions and procedures Provides logical structure to a program where programs are divided functions
In object oriented programming, program is divided into small parts called objects. In procedural programming, program is divided into small parts called functions.
Object oriented programming follows bottom up approach. Procedural programming follows top down approach.
Object oriented programming have access specifiers like private, public, protected etc. There is no access specifier in procedural programming.
Adding new data and function is easy. Adding new data and function is not easy.
Object oriented programming provides data hiding so it is more secure. Procedural programming does not have any proper way for hiding data so it is less secure.
Overloading is possible in object oriented programming. In procedural programming, overloading is not possible.
In object oriented programming, data is more important than function. In procedural programming, function is more important than data.
Object oriented programming is based on real world. Procedural programming is based on unreal world.
Examples: C++, Java, Python, C# etc. Examples: C, FORTRAN, Pascal, Basic etc.

Q3) What are the main features of OOPs?
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Data Abstraction

Q4) What is the difference between a class and a structure?
  • Class: User-defined blueprint from which objects are created. It consists of methods or set of instructions that are to be performed on the objects.
  • Structure: A structure is basically a user-defined collection of variables which are of different data types.

Q5) What is the difference between a class and an object?
    Object Class
    A real-world entity which is an instance of a class A class is basically a template or a blueprint within which objects can be created
    An object acts like a variable of the class Binds methods and data together into a single unit
    An object is a physical entity A class is a logical entity
    Objects take memory space when they are created A class does not take memory space when created
    Objects can be declared as and when required Classes are declared just once

    Q6) What is inheritance?

    Inheritance is a feature of OOPs which allows classes inherit common properties from other classes. For example, if there is a class such as ‘vehicle’, other classes like ‘car’, ‘bike’, etc can inherit common properties from the vehicle class. This property helps you get rid of redundant code thereby reducing the overall size of the code.

    Q7) What are the different types of inheritance?
    • Single inheritance
    • Multiple inheritance
    • Multilevel inheritance
    • Hierarchical inheritance
    • Hybrid inheritance

    Q8) What is the difference between multiple and multilevel inheritance?

    Multiple inheritance Multilevel inheritance
    Multiple inheritance comes into picture when a class inherits more than one base class Multilevel inheritance means a class inherits from another class which itself is a subclass of some other base class
    Example: A class defining a child inherits from two base classes Mother and Father Example: A class describing a sports car will inherit from a base class Car which inturn inherits another class Vehicle

    Q9) What is polymorphism?

    Polymorphism refers to the ability to exist in multiple forms. Multiple definitions can be given to a single interface. For example, if you have a class named Vehicle, it can have a method named speed but you cannot define it because different vehicles have different speed. This method will be defined in the subclasses with different definitions for different vehicles.

    Q10) What is method overloading?

    Method overloading is a feature of OOPs which makes it possible to give the same name to more than one methods within a class if the arguments passed differ.

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page