0% found this document useful (0 votes)
227 views

Object Oriented Programming Using C++ Viva Questions Coders Lodge

This document provides 30 questions and answers about object oriented programming concepts in C++. It covers topics such as classes, objects, functions, inheritance, polymorphism, encapsulation, and more. Learners are encouraged to practice the questions to build their understanding and score well on exams. The document also provides contact information to join online learning communities for additional support.

Uploaded by

Gulchetan Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
227 views

Object Oriented Programming Using C++ Viva Questions Coders Lodge

This document provides 30 questions and answers about object oriented programming concepts in C++. It covers topics such as classes, objects, functions, inheritance, polymorphism, encapsulation, and more. Learners are encouraged to practice the questions to build their understanding and score well on exams. The document also provides contact information to join online learning communities for additional support.

Uploaded by

Gulchetan Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

OBJECT ORIENTED PROGRAMMING

USING C++

Kindly read the instructions carefully

1. All these questions are important for examination point of view,


so practice them well.
2. If you have any doubt or facing any problem regarding these
questions you can mail us at [email protected] or
drop a message in our WhatsApp or telegram group.
3. If you want to support us, give your valuable feedback so that
next time we can improve while interacting with you.
4. Reminder-Practice all questions well it will build your concept
clear, and you can easily score good in your exams.

Connect with us
• If you want to join our WhatsApp community then mail us at:-
[email protected] with your preferred branch(with year) and
college name.
• Join our Telegram group:- https://t.me/coderslodgeofficial
• Like our Facebook page :- https://www.facebook.com/coderslodge
• Follow us on Instagram:-https://www.instagram.com/coderslodge/
• Follow us on Twitter:- https://twitter.com/CodersLodge
• Follow us on Linkedin:- https://www.linkedin.com/company/coderslodge

Kindly share your valuable feedback on


[email protected]
1. What is a class?
Class is a blue print which reflects the entities attributes and
actions. Technically defining a class is designing an user defined
data type.

2. What is an object?
An instance of the class is called as object.
3. Explain what is the use of void main () in C++ language?
To run the C++ application it involves two steps, the first step is
a compilation where conversion of C++ code to object code
take place. While second step includes linking, where
combining of object code from the programmer and from
libraries takes place. This function is operated by main () in C++
language.
4. Explain what is Member Functions in Classes?
The member function regulates the behaviour of the class. It
provides a definition for supporting various operations on data
held in the form of an object.
5. What is namespace std; and what is consists of?
Namespace std; defines your standard C++ library, it consists of
classes, objects and functions of the standard C++ library. You
can specify the library by using namespace std or std: :
throughout the code. Namespace is used to differentiate the
same functions in a library by defining the name.
6. Explain how functions are classified in C++ ?
In C++ functions are classified as
• Return type
Kindly share your valuable feedback on
[email protected]
• Function Name
• Parameters
• Function body
7. What is inheritance?
Inheritance is the process of acquiring the properties of the
exiting class into the new class. The existing class is called as
base/parent class and the inherited class is called as
derived/child class.
8. What is an inline function?
A function prefixed with the keyword inline before the function
definition is called as inline function. The inline functions are
faster in execution when compared to normal functions as the
compiler treats inline functions as macros.
9. Explain what is a reference variable in C++?
A reference variable is just like a pointer with few differences. It
is declared using & Operator. In other words, reference is
another name for an already existing variable.
10.Explain what is Polymorphism in C++?
Polymorphism in C++ is the ability to call different functions by
using only one type of the function call. Polymorphism is
referred to codes, operations or objects that behave differently
in a different context.
11.Explain what is C++ exceptional handling?
The problem that arises during execution of a program is
referred as exceptional handling. The exceptional handling in
C++ is done by three keywords.

Kindly share your valuable feedback on


[email protected]
• Try: It identifies a block of code for which particular
exceptions will be activated.
• Catch: The catch keyword indicates the catching of an
exception by an exception handler at the place in a
program.
• Throw: When a problem exists while running the code,
the program throws an exception.
12. Explain what is data encapsulation in C++?
Encapsulation is an object-oriented programming concept
(oops) which binds together the data and functions. It is also
referred as data hiding mechanism.
13. Mention what are the types of Member Functions?
The types of member functions are
• Simple functions
• Static functions
• Const functions
• Inline functions
• Friend functions
14. What is a pure virtual function?
A virtual function with no function body and assigned with a
value zero is called as pure virtual function.
15. What is role of static keyword on class member variable?
A static variable does exit though the objects for the respective
class are not created. Static member variable share a common
memory across all the objects created for the respective class.
A static member variable can be referred using the class name
itself.

Kindly share your valuable feedback on


[email protected]
16. Explain what is COPY CONSTRUCTOR and what is it used
for?
COPY CONSTRUCTOR is a technique that accepts an object of
the same class and copies its data member to an object on the
left part of the assignment.
17. Can we initialize a class/structure member variable as
soon as the same is defined?
No, Defining a class/structure is just a type definition and will
not allocated memory for the same.
18. What is function overloading?
Defining several functions with the same name with unique list
of parameters is called as function overloading.
19. What is operator overloading?
Defining a new job for the existing operator w.r.t the class
objects is called as operator overloading.
20. Name the default standard streams in C++.
cin, cout, cerr and clog.
21. What is a destructor? Can it be overloaded?
A destructor is the member function of the class which is having
the same name as the class name and prefixed with tilde (~)
symbol. It gets executed automatically w.r.t the object as soon
as the object loses its scope. It cannot be overloaded and the
only form is without the parameters.
22. Which operator can be used in C++ to allocate dynamic
memory?
‘new’ is the operator can be used for the same.
Kindly share your valuable feedback on
[email protected]
23. What is a friend function?
A function which is not a member of the class but still can
access all the member of the class is called so. To make it
happen we need to declare within the required class following
the keyword ‘friend’.
24. Are the exceptions and error same?
No, exceptions can be handled whereas program cannot
resolve errors.
25. What is function overriding?
Defining the functions within the base and derived class with
the same signature and name where the base class’s function is
virtual.
26. What is the difference between actual and formal
parameters?
The parameters sent to the function at calling end are called as
actual parameters while at the receiving of the function
definition called as formal parameters.
27. What is encapsulation?
The process of binding the data and the functions acting on the
data together in an entity (class) called as encapsulation.
28. When there are a Global variable and Local variable with
the same name, how will you access the global variable?
When there are two variables with the same name but
different scope, i.e., one is a local variable and the other is a
global variable, the compiler will give preference to a local
variable.

Kindly share your valuable feedback on


[email protected]
In order to access the global variable, we make use of a “scope
resolution operator (::)”. Using this operator, we can access the
value of the global variable.
29. What are the various Access Specifiers in C++?
C++ supports the following access specifiers:
• Public: Data members and functions are accessible
outside the class.
• Private: Data members and functions are not accessible
outside the class. The exception is the usage of a friend
class.
• Protected: Data members and functions are accessible
only to the derived classes.

30. What is the difference between Method Overloading and


Method Overriding in C++?
Method overloading is having functions with the same name
but different argument lists. This is a form of compile-time
polymorphism.
Method overriding comes into picture when we rewrite the
method that is derived from a base class. Method overriding is
used while dealing with run-time polymorphism or virtual
functions.

Kindly share your valuable feedback on


[email protected]

You might also like