You are on page 1of 10

1. What is a pure virtual function in C++?

a) A function that has a body

b) A function that is declared but not defined

c) A function that is declared with the 'pure' keyword

d) A function that is declared with the 'virtual' keyword

2. Which of the following is true about templates in C++?

a) Templates are instantiated at runtime

b) Templates are instantiated at compile time

c) Templates cannot be used with classes

d) Templates cannot be used with functions

3. Which type of inheritance allows a class to inherit from multiple base classes?

a) Single inheritance

b) Multiple inheritance

c) Hierarchical inheritance

d) Multilevel inheritance

4. What is the primary difference between a class template and a function template in C++?

a) Class templates can have static members

b) Function templates can have private members

c) Class templates can have multiple instantiations

d) Function templates can have default arguments

5. Which keyword is used to declare a constant member function in C++?

a) const

b) static

c) final

d) readonly

6. Which of the following is true about encapsulation in C++?


a) It allows data hiding and abstraction

b) It allows data sharing between classes

c) It allows access to private members from outside the class

d) It allows inheritance between classes

7. Which keyword is used to prevent a class from being inherited in C++?

a) final

b) sealed

c) const

d) static

8. Which keyword is used to define a template in C++?

a) template

b) generic

c) class

d) typedef

9. In C++, function overloading is an example of:

a) Inheritance

b) Encapsulation

c) Polymorphism

d) Abstraction

10. What is polymorphism in C++?

a) Ability to represent the same object in multiple forms

b) Ability to define multiple constructors in a class

c) Ability to define multiple functions with the same name but different arguments

d) Ability to create objects of different types

11. What is the purpose of a constructor in C++?

a) To initialize the object of a class


b) To destroy the object of a class

c) To perform calculations

d) To define member functions

12. Which of the following is a valid constructor in C++?

a) class MyClass() {}

b) MyClass() {}

c) constructor MyClass() {}

d) void constructor() {}

13. What is a class in C++?

a) A function

b) A data type

c) A loop

d) A variable

14. In C++, inheritance is a feature that allows:

a) A class to inherit from multiple classes

b) A class to inherit only from one class

c) A class to inherit from built-in types only

d) A class to inherit from itself

15. Which of the following is true about function overloading in C++?

a) Only one function can have the same name

b) Functions must have different names

c) Functions must have different return types

d) Functions must have the same number of arguments but different types

16. Which operator is used to access members of a class in C++?

a) .

b) ::
c) ->

d) :

17. Which keyword is used to denote inheritance in C++?

a) inherit

b) extends

c) inherits

d) :

18. Which access specifier allows members to be accessible only within the same class and its
derived classes?

a) public

b) private

c) protected

d) global

19. Which of the following is true about abstract classes in C++?

a) They cannot have member variables

b) They cannot have member functions

c) They cannot be instantiated

d) They cannot be inherited

20. Which of the following correctly defines a template function in C++?

a) template <typename T> void functionName(T arg) {}

b) template void functionName<T>(T arg) {}

c) void functionName<T> template(T arg) {}

d) void functionName(template <T> arg) {}

21What keyword is used to define a class in C++?

a) class

b) define
c) struct

d) object

22 Which of the following is true about objects in C++?

a) Objects are instances of classes

b) Objects cannot have member functions

c) Objects cannot have member variables

d) Objects are declared using the 'object' keyword

23. which keyword is used to declare a static member in a C++ class?

a) static

b) public

c) private

d) protected

24. Static members are shared among:

a) Different objects of the same class

b) Different classes

c) All objects of a program

d) None of the above

25. In C++, inheritance is a feature that allows:

a) A class to inherit from multiple classes

b) A class to inherit only from one class

c) A class to inherit from built-in types only

d) A class to inherit from itself

26. What is a template in C++?

a) A blueprint for creating objects

b) A function that takes variable number of arguments

c) A class that can operate with generic types


d) A predefined data structure

27. What is the purpose of a destructor in C++?

a) To initialize an object

b) To free resources when an object goes out of scope

c) To copy an object

d) To define member functions

28. Which of the following is NOT a type of inheritance supported by C++?

a) Single inheritance

b) Multiple inheritance

c) Hierarchical inheritance

d) Circular inheritance

29. In C++, function overloading is an example of:

a) Inheritance

b) Encapsulation

c) Polymorphism

d) Abstraction

30. What is polymorphism in C++?

a) Ability to represent the same object in multiple forms

b) Ability to define multiple constructors in a class

c) Ability to define multiple functions with the same name but different arguments

d) Ability to create objects of different types

31. What does the keyword 'virtual' do in C++?

a) It declares a function as pure virtual

b) It specifies that a function may be overridden in derived classes

c) It specifies that a function cannot be overridden in derived classes

d) It specifies that a function is static


32. Which operator is used to access members of a class in C++?

a) .

b) ::

c) ->

d) :

33. Which of the following is true about static member functions in C++?

a) They can access only static members of a class

b) They can access only non-static members of a class

c) They cannot access any members of a class

d) They can access both static and non-static members of a class

34. Which of the following statements about constructors is false?

a) Constructors cannot return values

b) Constructors have the same name as the class

c) Constructors can be overloaded

d) Constructors can be inherited

35. Which of the following is not a type of polymorphism in C++?

a) Compile-time polymorphism

b) Run-time polymorphism

c) Operator overloading

d) Encapsulation

36. Which operator is used to access members of a class in C++?

a) .

b) ::

c) ->

37. Which keyword is used to denote inheritance in C++?


a) inherit

b) extends

c) inherits

d) :

38. Which of the following correctly defines a template function in C++?

a) template <typename T> void functionName(T arg) {}

b) template void functionName<T>(T arg) {}

c) void functionName<T> template(T arg) {}

d) void functionName(template <T> arg) {}

39. What is the purpose of a copy constructor in C++?

a) To create a copy of an existing object

b) To initialize an object

c) To delete an object

d) To move an object

40. Which of the following is true about abstract classes in C++?

a) They cannot have member variables

b) They cannot have member functions

c) They cannot be instantiated

d) They cannot be inherited

Descriptive Questions (Long questions)


1 List and explain the different type of constructors.

2 Differentiate between C and C++.

3 Write object-oriented program to read and display record of an employee.

4 Write object-oriented program to calculate volume of cylinder.

5 Explain the types of inheritance with suitable example.

6 Explain Virtual function with suitable example.

7 Explain the concept of template using suitable program


8 Develop simple banking application using object-oriented approach with following functions.

Createaccount()

Deposit()

Withdraw()

Calculateinterest()

Checkbalance()

9. Write object-oriented program to add two complex numbers.

10. List and explain the features and advantages of Object-oriented Programming language

11. Explain Static members with the help of suitable example.

12 Explain Virtual function with suitable example.

13 Write object-oriented program to add two complex numbers.

14. Write object-oriented program to calculate factorial of a number.

15. WAP to implement the following inheritance

You might also like