0% found this document useful (0 votes)
18 views3 pages

C++ Viva

C++ is an object-oriented programming language that extends C with additional features like classes, objects, and inheritance. A class defines properties and behaviors that objects of that class can have. Object-oriented programming organizes code into reusable objects that encapsulate data and functions. Key concepts of OOP include inheritance, polymorphism, and encapsulation. A class is a template for objects, while an object is an instance of a class.

Uploaded by

Mohd Tausif
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)
18 views3 pages

C++ Viva

C++ is an object-oriented programming language that extends C with additional features like classes, objects, and inheritance. A class defines properties and behaviors that objects of that class can have. Object-oriented programming organizes code into reusable objects that encapsulate data and functions. Key concepts of OOP include inheritance, polymorphism, and encapsulation. A class is a template for objects, while an object is an instance of a class.

Uploaded by

Mohd Tausif
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/ 3

 What is C++?

Answer: C++ is a general-purpose programming language that was developed as an extension of the C
programming language. It supports both procedural and object-oriented programming paradigms.

 What is the difference between C and C++?


Answer: C++ is an extension of the C programming language and includes addi onal features such as classes,
objects, and inheritance that support object-oriented programming. C, on the other hand, is a procedural
programming language without built-in support for objects and classes.

 What is an object in C++?


Answer: An object in C++ is an instance of a class. It represents a specific en ty with its own set of data and
func ons.

 What is a class in C++?


Answer: A class in C++ is a user-defined data type that serves as a blueprint for crea ng objects. It defines
the proper es (data members) and behaviors (member func ons) that objects of that class can have.

 What is object-oriented programming (OOP)?


Answer: Object-oriented programming is a programming paradigm that organizes data and func ons into
reusable structures called objects. It emphasizes the concepts of encapsula on, inheritance, and
polymorphism.

 What is the difference between a class and an object?


Answer: A class is a blueprint or template for crea ng objects, while an object is an instance of a class. In
other words, a class defines the structure and behavior, and an object represents a specific instance of that
class.

 What is encapsula on?


Answer: Encapsula on is an object-oriented programming concept that combines data and the func ons that
operate on that data into a single unit called a class. It provides data hiding and protects the data from
external access.

 What is inheritance?
Answer: Inheritance is a mechanism in which one class inherits the proper es and behaviors of another
class. It allows for code reuse and establishes a hierarchical rela onship between classes.

 What is polymorphism?
Answer: Polymorphism is the ability of an object to take on many forms. In C++, it can be achieved through
func on overloading and func on overriding.
a feature

 What is the purpose of the using namespace statement in C++?


Answer: The using namespace statement is used to avoid having to write the namespace explicitly for each
iden fier from that namespace.

 What is a header file in C++?


Answer: A header file in C++ is a file that contains declara ons of func ons, classes, and variables, which can
be included in other C++ source files.

 What is the difference between the ++i and i++ increment operators?
Answer: The ++i is the prefix increment operator that increments the value of i and then returns the
incremented value. The i++ is the pos ix increment operator that returns the current value of i and then
increments it.

 Explain the difference between a reference and a pointer in C++.


Answer: A reference in C++ is an alias or alterna ve name for an exis ng variable, whereas a pointer is a
variable that holds the memory address of another variable.

 What is a constructor in C++?


Answer: A constructor in C++ is a special member func on that is automa cally called when an object of a
class is created. It is used to ini alize the object's data members.

 What is the difference between a shallow copy and a deep copy?


Answer: A shallow copy copies the values of the data members of one object to another, including any
pointers. A deep copy creates a completely new copy of the object, including dynamically allocated memory.

 What is func on overloading in C++?


Answer: Func on overloading is a feature in C++ that allows mul ple func ons with the same name but
different parameter lists to be defined. The compiler determines which func on to call based on the
arguments passed.

 What is operator overloading in C++?


Answer: Operator overloading is a feature in C++ that allows operators to be redefined or extended to work
with user-defined data types. For example, the + operator can be overloaded to concatenate two strings.

 What is the new operator used for in C++?


Answer: The new operator in C++ is used to dynamically allocate memory for an object or array.

 What is the delete operator used for in C++?


Answer: The delete operator in C++ is used to deallocate memory that was previously allocated with the new
operator.

 What is the difference between delete and delete[]?


Answer: The delete operator is used to deallocate memory for a single object, whereas the delete[] operator
is used to deallocate memory for an array of objects.

 What is the this pointer in C++?


Answer: The this pointer in C++ is a pointer that holds the memory address of the current object. It is used to
refer to the object's own members inside member func ons.

 What is the difference between a class and a structure in C++?


Answer: In C++, the only difference between a class and a structure is that the members of a class are private
by default, while the members of a structure are public by default.

 What is a virtual func on in C++?


Answer: A virtual func on in C++ is a func on that can be overridden in a derived class. It allows the correct
func on to be called based on the type of the object, even when using a pointer or reference to the base
class.

 What is a pure virtual func on?


Answer: A pure virtual func on is a virtual func on that is declared in a base class but has no

You might also like