Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ File Handling and Operator Overloading Quiz

Total questions: 77

Worksheet time: 39mins

Name
Class
Date
1.

getline() is used to:

a)

Read integer

b)

Read single word

c)

Read full line

d)

Write file

2.

put() function writes:

a)

String

b)

Integer

c)

Single character

d)

Object

3.

get() function reads:

a)

Integer

b)

Character

c)

Object

d)

Line

4.

Random access uses:

a)

get()

b)

put()

c)

seekg() / seekp()

d)

getline()

5.

Sequential access is best for:

a)

Databases

b)

Logs

c)

Searching records

d)

Random editing

6.

Binary file is faster because:

a)

Less memory used

b)

No conversion needed

c)

More readable

d)

ASCII format

7.

Object written to binary file must be:

a)

Static

b)

Simple data structure

c)

Pointer type

d)

Abstract

8.

While writing object to file, address is passed using:

a)

obj

b)

&obj

c)

*obj

d)

obj()

9.

read() function requires:

a)

Object

b)

Address of object

c)

File name

d)

Mode

10.

Structure written to binary file uses:

a)

sizeof(structure)

b)

sizeof(pointer)

c)

sizeof(file)

d)

sizeof(class)

11.

bad() function indicates:

a)

Logical error

b)

Serious I/O error

c)

EOF

d)

File closed

12.

Destructor is executed in:

a)

Same order as constructor

b)

Reverse order of constructor

c)

Random order

d)

Parallel

13.

Constructors are executed in inheritance in:

a)

Derived to base

b)

Base to derived

c)

Random order

d)

Parallel

14.

Destructor order in inheritance is:

a)

Base to derived

b)

Derived to base

c)

Random

d)

Same as constructor

15.

File handling is used to:

a)

Store data permanently

b)

Store data temporarily

c)

Store data in RAM

d)

Print data

16.

Text files store data in:

a)

Binary format

b)

Encrypted format

c)

Human-readable format

d)

Hex format

17.

Which function checks file open success?

a)

good()

b)

is_open()

c)

open()

d)

close()

18.

File streams inherit from:

a)

ios

b)

ostream

c)

istream

d)

stream

19.

ios::in | ios::out is used for:

a)

Read only

b)

Write only

c)

Read & write

d)

Append only

20.

Binary files are preferred for:

a)

Large data storage

b)

Text editing

c)

Reports

d)

Logs

21.

Destructor is not inherited because:

a)

It is private

b)

It is automatically called

c)

It has no parameters

d)

Only one allowed

22.

Constructor cannot be:

a)

Inline

b)

Overloaded

c)

Virtual

d)

Defined

23.

Which function moves file pointer from start?

a)

seekg(0)

b)

seekp(0)

c)

tellg()

d)

eof()

24.

seekg() stands for:

a)

Seek get pointer

b)

Seek global

c)

Seek generate

d)

Seek goto

25.

tellp() is related to:

a)

Reading

b)

Writing

c)

Opening

d)

Closing

26.

File handling improves:

a)

Speed only

b)

Data persistence

c)

CPU usage

d)

Compilation

27.

Operator overloading means:

a)

Redefining operator meaning

b)

Creating new operators

c)

Removing operators

d)

Hiding operators

28.

Main purpose of operator overloading is to:

a)

Increase speed

b)

Improve code readability

c)

Reduce memory

d)

Avoid inheritance

29.

Operator overloading provides:

a)

Flexibility

b)

Reusability

c)

Polymorphism

d)

All of the above

30.

Operator overloading is done using:

a)

function keyword

b)

operator keyword

c)

overload keyword

d)

virtual keyword

31.

Which operator cannot be overloaded?

a)

+

b)

-

c)

::

d)

*

32.

Unary operator works on:

a)

One operand

b)

Two operands

c)

Three operands

d)

No operand

33.

Which is a unary operator?

a)

+

b)

*

c)

++

d)

==

34.

Unary operator overloading function has:

a)

One parameter

b)

Two parameters

c)

No parameter

d)

Three parameters

35.

++ operator can be overloaded as:

a)

Binary operator only

b)

Unary operator only

c)

Both unary and binary

d)

Cannot be overloaded

36.

Binary operator works on:

a)

One operand

b)

Two operands

c)

Three operands

d)

None

37.

Binary operator overloading function has:

a)

No parameter

b)

One parameter

c)

Two parameters

d)

Three parameters

38.

Which is a binary operator?

a)

++

b)

--

c)

+

d)

!

39.

Binary operators are overloaded using:

a)

Member function

b)

Friend function

c)

Both A and B

d)

Constructor

40.

Which operator cannot be overloaded?

a)

sizeof

b)

.

c)

?:

d)

All of the above

41.

Operator overloading cannot change:

a)

Operator precedence

b)

Operator associativity

c)

Number of operands

d)

All of the above

42.

Type conversion means:

a)

Changing variable name

b)

Changing data type

c)

Changing operator

d)

Changing function

43.

Type conversion means:

a)

Changing variable name

b)

Changing data type

c)

Changing operator

d)

Changing function

44.

Conversion from int to float is:

a)

Class type to basic type

b)

Basic type to class type

c)

Basic type to basic type

d)

Class to class

45.

Conversion from basic to class type is done using:

a)

Destructor

b)

Parameterized constructor

c)

Copy constructor

d)

Virtual function

46.

Basic to class type conversion is:

a)

Implicit

b)

Explicit

c)

Automatic

d)

Using operator

47.

Class to basic type conversion is done using:

a)

Constructor

b)

Destructor

c)

Casting operator

d)

Inheritance

48.

Casting operator is defined using:

a)

operator datatype()

b)

datatype operator()

c)

cast operator

d)

convert operator

49.

Re-usability reduces:

a)

Memory

b)

Redundant code

c)

Execution time

d)

Compilation time

50.

Re-usability in C++ is achieved mainly using:

a)

Polymorphism

b)

Encapsulation

c)

Inheritance

d)

Abstraction

51.

Inheritance means:

a)

Creating objects

b)

Acquiring properties of another class

c)

Hiding data

d)

Overloading operators

52.

Parent class is also called:

a)

Derived class

b)

Child class

c)

Base class

d)

Friend class

53.

Child class is also called:

a)

Base class

b)

Derived class

c)

Friend class

d)

Abstract class

54.

Single inheritance involves:

a)

One base, one derived

b)

One base, many derived

c)

Many base, one derived

d)

Many base, many derived

55.

Multilevel inheritance involves:

a)

One level

b)

Two or more levels

c)

Multiple base classes

d)

Hybrid classes

56.

Multiple inheritance means:

a)

One base, many derived

b)

Many base, one derived

c)

One base, one derived

d)

No base

57.

Hierarchical inheritance means:

a)

Chain of classes

b)

Many base classes

c)

One base, many derived

d)

Mixed inheritance

58.

Hybrid inheritance is:

a)

Combination of inheritance types

b)

Single inheritance

c)

Multiple inheritance only

d)

Multilevel only

59.

Public inheritance means:

a)

Public remains public

b)

Protected remains protected

c)

Private remains private

d)

All of the above

60.

In private inheritance, public members become:

a)

Public

b)

Protected

c)

Private

d)

Inaccessible

61.

Protected inheritance makes public members:

a)

Public

b)

Protected

c)

Private

d)

Hidden

62.

Function overriding occurs in:

a)

Operator overloading

b)

Inheritance

c)

Templates

d)

File handling

63.

Overridden function has:

a)

Same name only

b)

Same signature

c)

Same return type only

d)

Different name

64.

Function overriding supports:

a)

Compile-time polymorphism

b)

Run-time polymorphism

c)

Data hiding

d)

Abstraction

65.

Constructor execution order in inheritance:

a)

Derived to base

b)

Base to derived

c)

Random

d)

Parallel

66.

Destructor execution order is:

a)

Base to derived

b)

Derived to base

c)

Random

d)

Same as constructor

67.

Ambiguity occurs in:

a)

Single inheritance

b)

Multiple inheritance

c)

Multilevel inheritance

d)

Hierarchical inheritance

68.

Ambiguity can be resolved using:

a)

Scope resolution operator

b)

Virtual function

c)

Constructor

d)

Destructor

69.

Virtual base class is used to:

a)

Increase speed

b)

Remove ambiguity

c)

Support encapsulation

d)

Improve security

70.

Virtual base class prevents:

a)

Multiple inheritance

b)

Diamond problem

c)

Function overriding

d)

Constructor execution

71.

Keyword used to declare virtual base class:

a)

virtual

b)

friend

c)

static

d)

inline

72.

Diamond problem occurs in:

a)

Single inheritance

b)

Multilevel inheritance

c)

Multiple inheritance

d)

Hierarchical inheritance

73.

Operator overloading is an example of:

a)

Inheritance

b)

Polymorphism

c)

Encapsulation

d)

Abstraction

74.

Type conversion operator is a:

a)

Constructor

b)

Destructor

c)

Member function

d)

Friend class

75.

In inheritance, private members are:

a)

Inherited

b)

Not accessible directly

c)

Protected

d)

Public

76.

Multiple inheritance increases:

a)

Ambiguity

b)

Simplicity

c)

Speed

d)

Security

77.

Virtual base class ensures:

a)

Single copy of base class

b)

Multiple copies

c)

Faster execution

d)

No inheritance