When an object-oriented program detects an error within a function, the function _________ A. throws an exception B. throws a fit C. catches a message D. catches an exception

[amp_mcq option1=”throws an exception” option2=”throws a fit” option3=”catches a message” option4=”catches an exception” correct=”option1″]

The correct answer is: A. throws an exception

An exception is an object that is created when a program encounters an error. The exception is then thrown, which means that it is passed up the call stack until it is handled by a function that is prepared to deal with it.

The other options are incorrect.

  • B. throws a fit is not a valid option.
  • C. catches a message is not a valid option. A message is a piece of information that is passed between objects. It is not an exception.
  • D. catches an exception is not a valid option. An exception is thrown, not caught.

I hope this helps! Let me know if you have any other questions.