You are on page 1of 2

VIVA Questions

C++

1. What is class?
Class is a user defined data types that contains both member data and member functions.
2. What is an object?
Object is an instances of a class (or) Object is a real world entity that contains attributes.
3. What are access specifiers?
Access specifiers are used to access the members of the class.
4. What are the different types of access specifiers?
1. Private 2. Public and 3. Protected
5. What is data encapsulation?
Wrapping of data and functions together in a unit is called data encapsulation.
6. What is data abstraction?
7. What is polymorphism?
The ability to make many forms. E.g Function overloading, Operator overloading.
8. What is function overloading?
Functions with same name but different arguments and data types.
9. What is operator overloading?
An operator to do more than one operation.
10. Give any two example for object oriented programming(OOP).
C++, java
11. What is inheritance?
The process of deriving a new class from the existing class.
12. What is base class or super class?
The existing class is called base or super class
13. What is sub class or derived class?
The new class is called sub class or derived class.
14. What are the different types of inheritance?
1. Single inheritance 2. Multiple 3. Multi level 4. Hierarchical 5. Hybrid
15. What is an inline function?
Inline is a short function. In this function call replaces the function definition.
16. What is member function?
The functions in a class is called member function.
17. Which keyword is used to define inline function?
Inline
Syntax inline datatype functionname(datatype var1, datatype var2…)
e.g inline int cube(int a)
18. What is friend function?
It is a non member function used to access the members of a class.
19. Is the keyword ‘friend’ can be used while defining the function?
No
20. Is the keyword ‘friend’ can be used while declaring the function?
Yes
21. How to define a friend function?
Like normal functions without the keyword ‘friend’.
22. What is constructors?
Constructor is a special member function has the same name as that of the class name.
23. Is the constructor function has return type?
No
24. In which section constructor function should be declared?
Public section
25. Mention the different types of constructors?
1. Default 2. Parameterized and 3. Copy constructor
26. What are default constructors?
A constructor with zero or no arguments is called default constructor
27. What is parameterized constructor?
A constructor with one or more arguments is called parameterized constructor.
28. What is copy constructor?
Copy constructor is used to copy the value of one object to another object.
29. What are the different ways to call the constructor function?
1. Implicit 2. Explicit 3. At the time of initialization
30. What are destructors?
Destructors are special member function which has the same name as that of class name
but it is preceded with tilde (~) symbol.
31. Why constructor functions are used?
Constructor functions are used to initialize the data members of a class.

You might also like