0

Exception Handling

Description: Exception Handling
Number of Questions: 15
Created by:
Tags: Exception Handling Java/Oracle /C/C++
Attempted 0/15 Correct 0 Score 0

In exception handling, which block throws an exception?

  1. Catch

  2. Throw

  3. Throws

  4. Try


Correct Option: D
Explanation:

The 'try' block can throw an exception. The catch block catches and processes the exception. 

An exception is a _____________.

  1. compile time error

  2. runtime error

  3. infinite loop

  4. none of these


Correct Option: B
Explanation:

An exception is an unwanted event that occurs during runtime and terminates the execution. Hence, an exception is nothing but a runtime error.

Which of the following is not an example of exception?

  1. Wrongly written inbuilt function

  2. Divide by zero error

  3. Array out of index error

  4. File not found error


Correct Option: A
Explanation:

Wrongly written inbuilt function gives the error in compile time. All the rest are runtime errors. 

In C++, the character type wchar_t is used to hold _______ wide character.

  1. 8 - bit

  2. 16 - bit

  3. 32 - bit

  4. 64 - bit


Correct Option: B
Explanation:

The new data type wchar_t in C++ is used to hold 16 - bit wide character. 

Which of the following statements is used to rethrow an exception?

  1. Throw(exception);

  2. Throw exception;

  3. Throw;

  4. Throws;


Correct Option: C
Explanation:

The statement to rethrow the exception is throw; i.e. throw without any specified exception. 

In order to make the C++ as a generic programming language, Alexander Stepanov and Meng Lee developed a set of general purpose templatised classes and functions. The collection of these classes and functions is called _____________.

  1. Standard Library(SL)

  2. Standard Template Library(STL)

  3. Standard Class Library(SCL)

  4. Standard Class and template Library(SCTL)


Correct Option: C
Explanation:

In C++, Standard Template Library(STL) contains the collection of templatised classes and functions. 

Which keyword allows the constant function to modify a particular data item only?

  1. Modify

  2. Mute

  3. Mutable

  4. Change


Correct Option: C
Explanation:

When the member variable is declared as a mutable, any constant function can modify the data items , i.e. it is declared as mutable. 

Which of the following is the correct sequence of statements for handling an error? A. Throw the exception B. Handle the exception C. Hit the exception D. Catch the exception

  1. ABCD

  2. ABDC

  3. BACD

  4. CADB


Correct Option: D
Explanation:

The correct sequence of statements to handle an error is

  1. Hit the exception
  2. Throw the exception
  3. Catch the exception
  4. Handle the exception

________________ is to used to find the exact type of the object using a pointer to the base class.

  1. RTTI

  2. RTIT

  3. RITT

  4. RTTT


Correct Option: A
Explanation:

Using Run Time Type Identification (RTTI), we can find the exact type of the object using a pointer to the base class. 

___________ defines a scope of the identifiers that are used in a program.

  1. Structure

  2. Union

  3. Namespace

  4. Class


Correct Option: D
Explanation:

Name space, a new concept is introduced in C++. Namespace defines a scope of the identifiers that are used in a program. 

When there is a requirement to convert a const(constant) to non-const(non constant), which keyword is to be used?

  1. cast_const

  2. no_const

  3. non_const

  4. const_cast


Correct Option: D
Explanation:

The const_cast can be used to convert a constant to non-constant. It can also be used to convert the data member of a class from the const functions.  

Which of the following statements is/are correct? A. Multiple catch clauses with one try block. B. Catch block only catches the exception.

  1. Only A

  2. Only B

  3. Both A and B

  4. Neither A nor B


Correct Option: A
Explanation:

There will be a multiple catch clause with one try block. The catch block not only catches the exception but it also processes the exception. 

Which of the following statements is/are correct? A. We can create a reference to an array. B. A reference is implicitly treated as constant pointer.

  1. Only A

  2. Only B

  3. Both A and B

  4. Neither A nor B


Correct Option: C
Explanation:

We can always create a reference to an array and also reference is implicitly treated as constant pointer. Because reference to a particular variable cannot point to another variable. 

The exception that is uncaught invokes the function _______.

  1. end()

  2. exit()

  3. terminate()

  4. block()


Correct Option: C
Explanation:

The uncaught exception calls the function terminate().

What is the meaning of following catch block? catch(...) { Statements; }

  1. Handle any exception that is not caught by other handlers

  2. Handle all I/O exceptions

  3. Handle all exceptions

  4. None of these


Correct Option: A
Explanation:

The ellipsis (...) is used by catch statement to handle all those exceptions that are not caught by other handlers. 

- Hide questions