CSC102 Final Exam |Questions with 100%
Correct Answers
What is the syntax of template and what does each parameter stand for? - ✔️✔️template <class
Type> declaration;
class- any user defined or built-in type
type- data type; formal parameter to the template
When does passing a parameter to a function take effect? - ✔️✔️at run time
When does passing a parameter to a class template take effect? - ✔️✔️at compile time
The implementation file cannot be compiled independently of the client code. - ✔️✔️True
The user can put class and function definition templates directly in the client code. - ✔️✔️True
The user can put class and function definition templates in the same header file. - ✔️✔️True
You can put class definitions and functions definitions in separate files. - ✔️✔️True
Function definitions and client codes are compiled together. - ✔️✔️True
An operator that has different meanings with different data types is said to be _____________.
- ✔️✔️Overloaded
Operator functions are ______-returning. - ✔️✔️Value
,Operator overloading provides the same concise notation for user-defined data types as for
built-in data types. - ✔️✔️True
Only existing operators can be overloaded. - ✔️✔️True
If an operator function is a member of a class, the leftmost operand must be a ________ object
of that operator's class. - ✔️✔️class
What is a parameterized type? - ✔️✔️a class template
What is an exception? - ✔️✔️An undesirable event in program execution
An exception-handling code can be added at a point where an error may occur. - ✔️✔️True
What does the assertion function do? - ✔️✔️Checks if an expressions meets certain conditions
and terminates if they are not met.
What is a try/catch block used for? - ✔️✔️To handle exceptions
Exception must be _____ in a try block and ______ by a catch block. - ✔️✔️thrown;caught
Statements that may generate an exception are placed in a _______ block. - ✔️✔️try
try block is followed by one or more catch blocks - ✔️✔️true
If the heading of a catch block contains (...) in place of parameters, that mean it can
catch_________. - ✔️✔️exceptions of all types
, If no exception is thrown in a try block, _________________. - ✔️✔️All catch blocks are ignored
and execution resumes after the last catch block.
If an exception is thrown in a try block, remaining statements are ____________. - ✔️✔️ignored
If the type of thrown exception matches the parameter type in one of the catch blocks, the
code of that block __________ and the remaining blocks are _________. - ✔️✔️executes;
ignored
A catch block can have at most _____ catch block parameter and becomes a placeholder for the
thrown value. - ✔️✔️one
For a try/catch block to work, the exception must be thrown in the ________. - ✔️✔️try block
Object being throw can only be a specific object. - ✔️✔️False; it can also be an anonymous
object.
An exception is a value. - ✔️✔️True
What can a catch block catch? - ✔️✔️All exceptions of a specific type and and all types of
exceptions
What does the WHAT function do? - ✔️✔️Returns a string containing the exception object
thrown by exception classes; tells you in words which exception object was thrown
What is a class exception? And what header file is it contained in? - ✔️✔️base class of the
exception classes;
exception
Correct Answers
What is the syntax of template and what does each parameter stand for? - ✔️✔️template <class
Type> declaration;
class- any user defined or built-in type
type- data type; formal parameter to the template
When does passing a parameter to a function take effect? - ✔️✔️at run time
When does passing a parameter to a class template take effect? - ✔️✔️at compile time
The implementation file cannot be compiled independently of the client code. - ✔️✔️True
The user can put class and function definition templates directly in the client code. - ✔️✔️True
The user can put class and function definition templates in the same header file. - ✔️✔️True
You can put class definitions and functions definitions in separate files. - ✔️✔️True
Function definitions and client codes are compiled together. - ✔️✔️True
An operator that has different meanings with different data types is said to be _____________.
- ✔️✔️Overloaded
Operator functions are ______-returning. - ✔️✔️Value
,Operator overloading provides the same concise notation for user-defined data types as for
built-in data types. - ✔️✔️True
Only existing operators can be overloaded. - ✔️✔️True
If an operator function is a member of a class, the leftmost operand must be a ________ object
of that operator's class. - ✔️✔️class
What is a parameterized type? - ✔️✔️a class template
What is an exception? - ✔️✔️An undesirable event in program execution
An exception-handling code can be added at a point where an error may occur. - ✔️✔️True
What does the assertion function do? - ✔️✔️Checks if an expressions meets certain conditions
and terminates if they are not met.
What is a try/catch block used for? - ✔️✔️To handle exceptions
Exception must be _____ in a try block and ______ by a catch block. - ✔️✔️thrown;caught
Statements that may generate an exception are placed in a _______ block. - ✔️✔️try
try block is followed by one or more catch blocks - ✔️✔️true
If the heading of a catch block contains (...) in place of parameters, that mean it can
catch_________. - ✔️✔️exceptions of all types
, If no exception is thrown in a try block, _________________. - ✔️✔️All catch blocks are ignored
and execution resumes after the last catch block.
If an exception is thrown in a try block, remaining statements are ____________. - ✔️✔️ignored
If the type of thrown exception matches the parameter type in one of the catch blocks, the
code of that block __________ and the remaining blocks are _________. - ✔️✔️executes;
ignored
A catch block can have at most _____ catch block parameter and becomes a placeholder for the
thrown value. - ✔️✔️one
For a try/catch block to work, the exception must be thrown in the ________. - ✔️✔️try block
Object being throw can only be a specific object. - ✔️✔️False; it can also be an anonymous
object.
An exception is a value. - ✔️✔️True
What can a catch block catch? - ✔️✔️All exceptions of a specific type and and all types of
exceptions
What does the WHAT function do? - ✔️✔️Returns a string containing the exception object
thrown by exception classes; tells you in words which exception object was thrown
What is a class exception? And what header file is it contained in? - ✔️✔️base class of the
exception classes;
exception