Home Computer Science Exception objects Python MCQ Questions and Answers Online Test

Exception objects Python MCQ Questions and Answers Online Test

350

Exception objects Python MCQ Questions and Answers Online Test

In Python, both built-in and user-defined exceptions are identified by class instance objects. Although this means you must use object-oriented programming to define new exceptions in your programs, classes, and OOP in general offer a number of benefits.

Here are some of the advantages of class-based exceptions:

  • They can be organized into categories. Exception classes support future changes by providing categories—adding new exceptions in the future won’t generally require changes in try statements.
  • They have attached state information. Exception classes provide a natural place for us to store context information for use in the try handler—they may have both attached state information and callable methods, accessible through instances.
  • They support inheritance. Class-based exceptions can participate in inheritance hierarchies to obtain and customize common behavior—inherited display methods, for example, can provide a common look and feel for error messages.

Because of these advantages, class-based exceptions support program evolution and larger systems well. In fact, all built-in exceptions are identified by classes and are organized into an inheritance tree, for the reasons just listed. You can do the same with user-defined exceptions of your own.

Quiz Description: 

Name: Exception objects Python MCQ Questions and Answers Online Test

Subject:  Python

Topic:  Exception objects

Questions: 15 Objective Type Questions

Time Allowed: 15 Minutes

Language: English

Important for:  B. Tech. / M. Tech. Students, B.Sc. / M.Sc. (CS / IT) and aspirants of competitive exams, computer science job interviews, Python job interviews, etc.

Created By: Esha Tripathi

Previous QuizNCERT Class 11 Accountancy book 1 Chapter 7 MCQ online test – Depreciation, Provisions and Reserves
Next QuizUnicode and Byte Strings Python MCQ Questions and Answers Online Test

LEAVE A REPLY

Please enter your comment!
Please enter your name here