0% found this document useful (0 votes)
37 views2 pages

C++ Viva Questions

The document contains a series of C++ viva questions categorized into basic, intermediate, and advanced levels. It covers fundamental concepts such as data types, classes, inheritance, polymorphism, and encapsulation, along with more advanced topics like operator overloading and friend functions. Each question is paired with a concise answer to aid in understanding key C++ programming principles.

Uploaded by

Siya Bhatia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

C++ Viva Questions

The document contains a series of C++ viva questions categorized into basic, intermediate, and advanced levels. It covers fundamental concepts such as data types, classes, inheritance, polymorphism, and encapsulation, along with more advanced topics like operator overloading and friend functions. Each question is paired with a concise answer to aid in understanding key C++ programming principles.

Uploaded by

Siya Bhatia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Viva Questions

Basic Level
Q: What is C++?

A: C++ is an object-oriented programming language developed by Bjarne Stroustrup as an

extension of C.

Q: What are the basic data types in C++?

A: `int`, `float`, `char`, `double`, `bool`, etc.

Q: What is the difference between C and C++?

A: C is procedural, C++ supports both procedural and object-oriented programming.

Q: What is a class and object?

A: A class is a blueprint for objects. An object is an instance of a class.

Q: What is a constructor?

A: A constructor is a special member function that is automatically called when an object is created.

Intermediate Level
Q: What is inheritance?

A: Inheritance allows one class to inherit the properties and methods of another class.

Q: What is polymorphism?

A: Polymorphism allows functions or methods to behave differently based on the object that calls

them.

Q: What is encapsulation?

A: Encapsulation is the process of wrapping data and functions into a single unit (class).

Q: What is abstraction?

A: Abstraction hides complex implementation details and shows only the necessary features.

Q: What is a virtual function?


A: A function declared in a base class and meant to be overridden in derived classes.

Advanced Level
Q: What is the difference between `struct` and `class` in C++?

A: By default, members of a `struct` are public, while in a `class`, they are private.

Q: What is operator overloading?

A: It allows you to redefine the way operators work for user-defined types.

Q: What is the difference between compile time and runtime polymorphism?

A: Compile-time (e.g., function overloading), runtime (e.g., virtual functions).

Q: What is a friend function?

A: A function that can access the private and protected members of a class.

Q: What is the use of the `this` pointer?

A: It is used to refer to the calling object inside a class method.

You might also like