• +91 9723535972
  • info@interviewmaterial.com

OOP Interview Questions and Answers

OOP Interview Questions and Answers

Question - 31 : - What is an object?

Answer - 31 : -

An object is a real-world entity which is the basic unit of OOPs for example chair, cat, dog, etc. Different objects have different states or attributes, and behaviors.

Question - 32 : - What is a class?

Answer - 32 : -

A class is a prototype that consists of objects in different states and with different behaviors. It has a number of methods that are common the objects present within that class.

Question - 33 : - What is the difference between a class and a structure?

Answer - 33 : -

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.

Question - 34 : -
Can you call the base class method without creating an instance?

Answer - 34 : -

Yes, you can call the base class without instantiating it if:

  • It is a static method
  • The base class is inherited by some other subclass

Question - 35 : - What is the difference between a class and an object?

Answer - 35 : -

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

Question - 36 : - What is inheritance?

Answer - 36 : -

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.

Question - 37 : - What are the different types of inheritance?

Answer - 37 : -

  • Single inheritance
  • Multiple inheritance
  • Multilevel inheritance
  • Hierarchical inheritance
  • Hybrid inheritance

Question - 38 : - What is hybrid inheritance?

Answer - 38 : -

Hybrid inheritance is a combination of multiple and multi-level inheritance.

Question - 39 : - What is hierarchical inheritance?

Answer - 39 : -

Hierarchical inheritance refers to inheritance where one base class has more than one subclasses. For example, the vehicle class can have ‘car’, ‘bike’, etc as its subclasses.

Question - 40 : - What are the limitations of inheritance?

Answer - 40 : -

  • Increases the time and effort required to execute a program as it requires jumping back and forth between different classes
  • The parent class and the child class get tightly coupled
  • Any modifications to the program would require changes both in the parent as well as the child class
  • Needs careful implementation else would lead to incorrect results


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners