inheritance polymorphism

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

50 Terms

1
New cards

Which feature of OOP allows a class to derive properties from another class?

Inheritance

3 multiple choice options

2
New cards

Which access specifier allows members to be accessed in derived classes but not outside?

Protected

3 multiple choice options

3
New cards

What is the keyword used to inherit a class in C++?

:

3 multiple choice options

4
New cards

Which of the following correctly declares a class B derived from class A?

class B : public A

3 multiple choice options

5
New cards

What is the default access specifier for inheritance in C++?

Private

3 multiple choice options

6
New cards

Which function is used to override a base class method in C++?

A virtual function

3 multiple choice options

7
New cards

What is required in base class to achieve runtime polymorphism?

At least one virtual function

3 multiple choice options

8
New cards

Which keyword allows method overriding in a derived class?

override

3 multiple choice options

9
New cards

What is the purpose of virtual functions?

To achieve runtime polymorphism

3 multiple choice options

10
New cards

What is the output type of a virtual function call resolved at runtime

Dynamic Binding

3 multiple choice options

11
New cards

Which type of inheritance is supported in C++?

All of the above

3 multiple choice options

12
New cards

Which of the following is not a distinct syntax-defined form of inheritance in C++?

Hybrid

3 multiple choice options

13
New cards

Which keyword prevents further inheritance of a class?

final

3 multiple choice options

14
New cards

What happens if a class has a pure virtual function?

It becomes an abstract class

3 multiple choice options

15
New cards

Which of these cannot be instantiated?

Abstract class

3 multiple choice options

16
New cards

What is it called when a derived class redefines a method of its base class?

Overriding

3 multiple choice options

17
New cards

Which class is automatically called when an object of derived class is created?

Base class constructor

3 multiple choice options

18
New cards

Which of these is an example of single inheritance?

class B : public A

3 multiple choice options

19
New cards

Which of the following enables function overloading?

Different parameter types

3 multiple choice options

20
New cards

Which of these is an example of function overriding?

Same function signature in base and derived class

3 multiple choice options

21
New cards

What does the keyword virtual do in a base class?

Ensures the correct derived class function is called

3 multiple choice options

22
New cards

Which keyword is used to prevent a method from being overridden?

final

3 multiple choice options

23
New cards

Which inheritance allows a class to inherit from multiple classes?

Multiple

3 multiple choice options

24
New cards

What happens when a method is both virtual and overridden?

The derived class is invoked at runtime

3 multiple choice options

25
New cards

What is a base class?

The class whose properties are inherited

3 multiple choice options

26
New cards

Which of these is true about virtual destructors?

They ensure proper cleanup of derived objects

3 multiple choice options

27
New cards

Which of the following defines pure virtual function?

virtual void func() = 0;

3 multiple choice options

28
New cards

Which of the following allows polymorphism?

Virtual functions

3 multiple choice options

29
New cards

Which function binding happens at compile-time?

Static binding

30
New cards

Which function binding happens at run-time?

Dynamic binding

3 multiple choice options

31
New cards

In C++, a class inherits from another class using the ________ symbol.

colon (:)

32
New cards

A class that provides members to another class is known as the ________ class.

base

33
New cards

A class that receives members from another class is called the ________ class.

derived

34
New cards

To override a base class function in the derived class, the function must be marked as ________ in the base class.

virtual

35
New cards

C++ supports ________ inheritance where a class is derived from more than one base class.

multiple

36
New cards

A function with the same name and parameters in the derived class as in the base class is called

overriding

37
New cards

The process of defining the same function in multiple forms is called

polymorphism

38
New cards

A class that contains at least one pure virtual function is known as an ________ class.

abstract

39
New cards

The keyword ________ is used to define a function that can be overridden in a derived class.

virtual

40
New cards

Function overloading is an example of ________ polymorphism

compile-time

41
New cards

Function overriding is an example of ________ polymorphism

runtime

42
New cards

C++ resolves overloaded functions using the function's ________ list.

parameter

43
New cards

Inheritance allows for ________ of code from base to derived classes

reusability

44
New cards

The ________ specifier prevents a class from being used as a base class

final

45
New cards

Only ________ and protected members are accessible in a derived class

public

46
New cards

A ________ function must be overridden in all derived classes to avoid compilation errors

pure virtual

47
New cards

The base class destructor should be declared as ________ to ensure proper cleanup

virtual

48
New cards

In hierarchical inheritance, multiple classes inherit from a single ________ class.

base

49
New cards

When a derived class modifies the behavior of a function from the base class, it is called

function overriding

50
New cards

A pointer to a base class can point to a derived class object, enabling ________ behavior

polymorphic