• +91 9723535972
  • info@interviewmaterial.com

OOP Interview Questions and Answers

OOP Interview Questions and Answers

Question - 71 : - What is meant by Structured Programming?

Answer - 71 : -

Structured Programming refers to the method of programming which consists of a completely structured control flow. Here structure refers to a block, which contains a set of rules, and has a definitive control flow, such as (if/then/else), (while and for), block structures, and subroutines.

Nearly all programming paradigms include Structured programming, including the OOPs model.

Question - 72 : - What are some advantages of using OOPs?

Answer - 72 : -

  • OOPs is very helpful in solving very complex level of problems.
  • Highly complex programs can be created, handled, and maintained easily using object-oriented programming.
  • OOPs, promote code reuse, thereby reducing redundancy.
  • OOPs also helps to hide the unnecessary details with the help of Data Abstraction.
  • OOPs, are based on a bottom-up approach, unlike the Structural programming paradigm, which uses a top-down approach.
  • Polymorphism offers a lot of flexibility in OOPs.

Question - 73 : - Why is OOPs so popular?

Answer - 73 : -

OOPs programming paradigm is considered as a better style of programming. Not only it helps in writing a complex piece of code easily, but it also allows users to handle and maintain them easily as well. Not only that, the main pillar of OOPs - Data Abstraction, Encapsulation, Inheritance, and Polymorphism, makes it easy for programmers to solve complex scenarios. As a result of these, OOPs is so popular.

Question - 74 : - How does C++ support Polymorphism?

Answer - 74 : -

C++ is an Object-oriented programming language and it supports Polymorphism as well:

  • Compile Time Polymorphism: C++ supports compile-time polymorphism with the help of features like templates, function overloading, and default arguments.
  • Runtime Polymorphism: C++ supports Runtime polymorphism with the help of features like virtual functions. Virtual functions take the shape of the functions based on the type of object in reference and are resolved at runtime.

Question - 75 : - What is meant by Inheritance?

Answer - 75 : -

The term “inheritance” means “receiving some quality or behavior from a parent to an offspring.” In object-oriented programming, inheritance is the mechanism by which an object or class (referred to as a child) is created using the definition of another object or class (referred to as a parent). Inheritance not only helps to keep the implementation simpler but also helps to facilitate code reuse.

Question - 76 : - What is Abstraction?

Answer - 76 : -

If you are a user, and you have a problem statement, you don't want to know how the components of the software work, or how it's made. You only want to know how the software solves your problem. Abstraction is the method of hiding unnecessary details from the necessary ones. It is one of the main features of OOPs. 
For example, consider a car. You only need to know how to run a car, and not how the wires are connected inside it. This is obtained using Abstraction.

Question - 77 : - How much memory does a class occupy?

Answer - 77 : -

Classes do not consume any memory. They are just a blueprint based on which objects are created. Now when objects are created, they actually initialize the class members and methods and therefore consume memory.

Question - 78 : - Is it always necessary to create objects from class?

Answer - 78 : -

No. An object is necessary to be created if the base class has non-static methods. But if the class has static methods, then objects don’t need to be created. You can call the class method directly in this case, using the class name.

Question - 79 : - What are the various types of constructors in C++?

Answer - 79 : -

The most common classification of constructors includes:

Default constructor: The default constructor is the constructor which doesn’t take any argument. It has no parameters.

class ABC
{
   int x;
      
   ABC()
   {
       x = 0;
   }
}
Parameterized constructor: The constructors that take some arguments are known as parameterized constructors.

 class ABC
{
   int x;
      
   ABC(int y)
   {
       x = y;
   }
}
Copy constructor: A copy constructor is a member function that initializes an object using another object of the same class.

class ABC
{
   int x;
      
   ABC(int y)
   {
       x = y;
   }
   // Copy constructor
   ABC(ABC abc)
   {
       x = abc.x;
   }
}

Question - 80 : - Are class and structure the same? If not, what's the difference between a class and a structure?

Answer - 80 : -

No, class and structure are not the same. Though they appear to be similar, they have differences that make them apart. For example, the structure is saved in the stack memory, whereas the class is saved in the heap memory. Also, Data Abstraction cannot be achieved with the help of structure, but with class, Abstraction is majorly used.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners