MCQOPTIONS
Saved Bookmarks
This section includes 5 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Suppose B is a subclass of A, to invoke the __init__ method in A from B, what is the line of code you should write?$ |
| A. | A.__init__(self) |
| B. | B.__init__(self) |
| C. | A.__init__(B) |
| D. | B.__init__(A) |
| Answer» C. A.__init__(B) | |
| 2. |
Error, the syntax of the invoking method is wrong |
| A. | The program runs fine but nothing is printed |
| B. | 1 0 |
| C. | 1 2 |
| Answer» C. 1 2 | |
| 3. |
Error because class B inherits A but variable x isn’t inherited$ |
| A. | 0 0 |
| B. | 0 1 |
| C. | Error, the syntax of the invoking method is wrong |
| Answer» D. | |
| 4. |
Invalid syntax for inheritance |
| A. | Error because when object is created, argument must be passed |
| B. | Nothing is printed |
| C. | A disp() |
| Answer» B. Nothing is printed | |
| 5. |
0 1 |
| A. | 0 0 |
| B. | Error because class B inherits A but variable x isn’t inherited |
| C. | Error because when object is created, argument must be passed like Derived_Test(1) |
| Answer» C. Error because when object is created, argument must be passed like Derived_Test(1) | |