LearnFrenzy
Sign in Take a free test

C++ Programming · Topic 8 of 27

OOPS Concepts

  • 4 exercises
  • 60 questions
  • ~60 min
  • Answers explained

Interview Questions

OOPS Concepts · Study material

C++ OOPS Concepts – Interview Questions

1. What is object-oriented programming?

A programming paradigm that organises software as objects combining data and behaviour, built on encapsulation, abstraction, inheritance and polymorphism.

2. What is the difference between a class and an object?

A class is a type – a blueprint describing data and functions. An object is a concrete instance of that class occupying memory, with its own values.

3. What is encapsulation?

Bundling data with the functions that operate on it and restricting direct access to the data (private members), so the class controls how its state changes.

4. What is abstraction, and how is it different from encapsulation?

Abstraction exposes only the essential interface and hides implementation details (abstract classes, interfaces). Encapsulation is the mechanism of hiding the data itself. Abstraction is about design, encapsulation about implementation.

5. What is inheritance? Name its types.

Deriving a class from another to reuse and extend it. Types: single, multiple, multilevel, hierarchical and hybrid.

6. What is polymorphism? Name its types.

The ability of one interface to work with different types. Compile-time: function overloading, operator overloading, templates. Run-time: virtual functions with dynamic binding.

7. What is the difference between overloading and overriding?

Overloading: same name, different parameters, in the same scope, resolved at compile time. Overriding: a derived class redefines a base virtual function with the same signature, resolved at run time.

8. What is a virtual function?

A member function declared virtual in a base class, whose call through a base pointer or reference is dispatched to the most-derived override at run time.

9. What is a pure virtual function and an abstract class?

A pure virtual function is declared with = 0 and has no required implementation; a class containing one is abstract and cannot be instantiated.

10. What is a vtable?

A per-class table of pointers to virtual function implementations; each polymorphic object holds a hidden pointer (vptr) to its class's table, used to dispatch virtual calls.

11. Why does a base class need a virtual destructor?

Without it, deleting a derived object through a base pointer calls only the base destructor – undefined behaviour and usually a resource leak.

12. What is the this pointer?

An implicit pointer, available in non-static member functions, to the object on which the function was called.

13. What is a static member?

A data member shared by all objects of a class, or a member function that belongs to the class and has no this pointer.

14. What is the difference between composition and inheritance?

Composition is HAS-A (a class contains objects of other classes); inheritance is IS-A. Composition gives looser coupling and is usually preferred unless polymorphic substitution is needed.

15. What is object slicing?

When a derived object is copied into a base object by value, the derived part is cut off; virtual calls on the copy use the base implementation.

16. What are access specifiers?

public, protected and private – they control which code may access class members.

17. What is the difference between struct and class in C++?

Default access: public for struct, private for class (both for members and base classes). Otherwise they are identical.

18. What is dynamic binding?

Choosing which function body to execute at run time based on the actual object type, as with virtual function calls.

19. What is a friend function?

A non-member function granted access to a class's private and protected members by a friend declaration inside the class. It weakens encapsulation and should be used sparingly (e.g. operator<<).

20. What are the SOLID principles?

Single responsibility, open/closed, Liskov substitution, interface segregation and dependency inversion – guidelines for maintainable object-oriented design.

Ready to test your Programming?

Timed online tests with instant scores and explanations.

About this section

About C++ Programming

C++ adds object-oriented programming, templates and the powerful Standard Template Library (STL) to C. It powers game engines, browsers, trading systems and most competitive programming. This section takes you from basic syntax to classes, inheritance, polymorphism, modern C++ (C++11 to C++23) and the STL – every concept with runnable examples and practice questions checked on a real compiler.

Why it matters

  • OOP concepts – classes, inheritance, polymorphism, encapsulation – are asked in almost every interview
  • C++ with the STL is the most popular language for competitive programming and DSA rounds
  • Questions on constructors, virtual functions, references and smart pointers decide technical rounds
  • Modern C++ skills are in demand at product companies, fintech and game studios

Who it is for

  • School students (Class 11–12 computer science with C++) preparing for board exams and practicals
  • College students (B.Tech, BCA, MCA) learning OOP and data structures for semester exams and labs
  • Freshers preparing for placements, coding tests and C++ technical interviews
  • Competitive programmers who want to master the STL

What every topic gives you

  • Study material in five tabs: concepts with runnable examples, coding techniques, programs, interview questions and a cheat sheet
  • MCQs that check your understanding of every concept
  • "Predict the output" puzzles – the trickiest part of written tests
  • "Find the error" programs that train you to spot bugs quickly
  • Complete programs with solutions and real output, verified on a compiler

Asked in

  • Campus placements
  • Product company interviews
  • Coding rounds & DSA
  • Competitive programming
  • GATE CS
  • University exams

How to use this section

  1. Read the study material of a topic and run the examples yourself.
  2. Practise the four exercises – MCQs, output, errors, programs – and read every explanation.
  3. Test yourself with the timed online test, then revise the topics you got wrong.

Search LearnFrenzy

Esc

Quick links