WorksheetsC++ File Handling and Operator Overloading Quiz
Total questions: 77
Worksheet time: 39mins
getline() is used to:
Read integer
Read single word
Read full line
Write file
put() function writes:
String
Integer
Single character
Object
get() function reads:
Integer
Character
Object
Line
Random access uses:
get()
put()
seekg() / seekp()
getline()
Sequential access is best for:
Databases
Logs
Searching records
Random editing
Binary file is faster because:
Less memory used
No conversion needed
More readable
ASCII format
Object written to binary file must be:
Static
Simple data structure
Pointer type
Abstract
While writing object to file, address is passed using:
obj
&obj
*obj
obj()
read() function requires:
Object
Address of object
File name
Mode
Structure written to binary file uses:
sizeof(structure)
sizeof(pointer)
sizeof(file)
sizeof(class)
bad() function indicates:
Logical error
Serious I/O error
EOF
File closed
Destructor is executed in:
Same order as constructor
Reverse order of constructor
Random order
Parallel
Constructors are executed in inheritance in:
Derived to base
Base to derived
Random order
Parallel
Destructor order in inheritance is:
Base to derived
Derived to base
Random
Same as constructor
File handling is used to:
Store data permanently
Store data temporarily
Store data in RAM
Print data
Text files store data in:
Binary format
Encrypted format
Human-readable format
Hex format
Which function checks file open success?
good()
is_open()
open()
close()
File streams inherit from:
ios
ostream
istream
stream
ios::in | ios::out is used for:
Read only
Write only
Read & write
Append only
Binary files are preferred for:
Large data storage
Text editing
Reports
Logs
Destructor is not inherited because:
It is private
It is automatically called
It has no parameters
Only one allowed
Constructor cannot be:
Inline
Overloaded
Virtual
Defined
Which function moves file pointer from start?
seekg(0)
seekp(0)
tellg()
eof()
seekg() stands for:
Seek get pointer
Seek global
Seek generate
Seek goto
tellp() is related to:
Reading
Writing
Opening
Closing
File handling improves:
Speed only
Data persistence
CPU usage
Compilation
Operator overloading means:
Redefining operator meaning
Creating new operators
Removing operators
Hiding operators
Main purpose of operator overloading is to:
Increase speed
Improve code readability
Reduce memory
Avoid inheritance
Operator overloading provides:
Flexibility
Reusability
Polymorphism
All of the above
Operator overloading is done using:
function keyword
operator keyword
overload keyword
virtual keyword
Which operator cannot be overloaded?
+
-
::
*
Unary operator works on:
One operand
Two operands
Three operands
No operand
Which is a unary operator?
+
*
++
==
Unary operator overloading function has:
One parameter
Two parameters
No parameter
Three parameters
++ operator can be overloaded as:
Binary operator only
Unary operator only
Both unary and binary
Cannot be overloaded
Binary operator works on:
One operand
Two operands
Three operands
None
Binary operator overloading function has:
No parameter
One parameter
Two parameters
Three parameters
Which is a binary operator?
++
--
+
!
Binary operators are overloaded using:
Member function
Friend function
Both A and B
Constructor
Which operator cannot be overloaded?
sizeof
.
?:
All of the above
Operator overloading cannot change:
Operator precedence
Operator associativity
Number of operands
All of the above
Type conversion means:
Changing variable name
Changing data type
Changing operator
Changing function
Type conversion means:
Changing variable name
Changing data type
Changing operator
Changing function
Conversion from int to float is:
Class type to basic type
Basic type to class type
Basic type to basic type
Class to class
Conversion from basic to class type is done using:
Destructor
Parameterized constructor
Copy constructor
Virtual function
Basic to class type conversion is:
Implicit
Explicit
Automatic
Using operator
Class to basic type conversion is done using:
Constructor
Destructor
Casting operator
Inheritance
Casting operator is defined using:
operator datatype()
datatype operator()
cast operator
convert operator
Re-usability reduces:
Memory
Redundant code
Execution time
Compilation time
Re-usability in C++ is achieved mainly using:
Polymorphism
Encapsulation
Inheritance
Abstraction
Inheritance means:
Creating objects
Acquiring properties of another class
Hiding data
Overloading operators
Parent class is also called:
Derived class
Child class
Base class
Friend class
Child class is also called:
Base class
Derived class
Friend class
Abstract class
Single inheritance involves:
One base, one derived
One base, many derived
Many base, one derived
Many base, many derived
Multilevel inheritance involves:
One level
Two or more levels
Multiple base classes
Hybrid classes
Multiple inheritance means:
One base, many derived
Many base, one derived
One base, one derived
No base
Hierarchical inheritance means:
Chain of classes
Many base classes
One base, many derived
Mixed inheritance
Hybrid inheritance is:
Combination of inheritance types
Single inheritance
Multiple inheritance only
Multilevel only
Public inheritance means:
Public remains public
Protected remains protected
Private remains private
All of the above
In private inheritance, public members become:
Public
Protected
Private
Inaccessible
Protected inheritance makes public members:
Public
Protected
Private
Hidden
Function overriding occurs in:
Operator overloading
Inheritance
Templates
File handling
Overridden function has:
Same name only
Same signature
Same return type only
Different name
Function overriding supports:
Compile-time polymorphism
Run-time polymorphism
Data hiding
Abstraction
Constructor execution order in inheritance:
Derived to base
Base to derived
Random
Parallel
Destructor execution order is:
Base to derived
Derived to base
Random
Same as constructor
Ambiguity occurs in:
Single inheritance
Multiple inheritance
Multilevel inheritance
Hierarchical inheritance
Ambiguity can be resolved using:
Scope resolution operator
Virtual function
Constructor
Destructor
Virtual base class is used to:
Increase speed
Remove ambiguity
Support encapsulation
Improve security
Virtual base class prevents:
Multiple inheritance
Diamond problem
Function overriding
Constructor execution
Keyword used to declare virtual base class:
virtual
friend
static
inline
Diamond problem occurs in:
Single inheritance
Multilevel inheritance
Multiple inheritance
Hierarchical inheritance
Operator overloading is an example of:
Inheritance
Polymorphism
Encapsulation
Abstraction
Type conversion operator is a:
Constructor
Destructor
Member function
Friend class
In inheritance, private members are:
Inherited
Not accessible directly
Protected
Public
Multiple inheritance increases:
Ambiguity
Simplicity
Speed
Security
Virtual base class ensures:
Single copy of base class
Multiple copies
Faster execution
No inheritance
