click below
click below
Normal Size Small Size show me how
F6 PY
| Question | Answer |
|---|---|
| The __init__() function is always executed when the class is being initiated. | True |
| Python is an object oriented programming language. | True |
| A single underscore _ prefixed to a variable makes it private. | False |
| Class in objects are functions that belong to the object. | False |
| If you for some reason have a class definition with no content, put in the pass statement to avoid getting an error. | True |
| The arrangement of private instance variables and public methods ensures the principle of data encapsulation. | True |
| Use the __init__() function to assign values to object properties, or other operations that are necessary to do when the object is being created. | True |
| An instance attribute can be accessed using dot notation. | True |
| Python's convention to make an instance variable protected is to add a prefix __ (double underscore) to it. | False |
| You can not use the else keyword to define a block of code to be executed if no errors were raised. | False |
| You can define as many exception blocks as you want. | True |
| Can one block of except statements handle multiple exception? Choices: none of the mentioned yes, like except TypeError, SyntaxError [,…] yes, like except [TypeError, SyntaxError] no | none of the mentioned |
| Instance attributes and methods defined in the child class will be inherited by the object of the parent class. | False |
| What relationship is appropriate for Fruit and Papaya? | inheritance |
| Methods of the child class are available for use in the inherited class. | False |
| A quadrilateral class having four sides as instance variables and a area() method is defined. | True |
| You can use the else keyword to define a block of code to be executed if no errors were raised. | True |
| You can not define as many exception blocks as you want. | False |
| When is the finally block executed? | always |
| What will be the output of the following Python code? class fruits: def __init__(self, price): self.price = price obj = fruits(50) obj.quantity = 10 obj.bags = 2 print(obj.quantity + len(obj.__dict__)) Choices: 53 / 10 / 60 / 13 | 13 |
| What does print(Test.__name__) display (assuming Test is the name of the class)? Making the code look clean Recursive calls take up less memory Sequence generation is easier than a nested iteration A complex task can be broken into sub-problems | Test |
| The object of the same class is required to invoke a public method. | False |
| Python doesn't have any mechanism that effectively restricts access to any instance variable or method. | True |
| If you for some reason have a class definition with no content, put in the delete statement to avoid getting an error. | False |
| Which is true? When there is a deviation from the rules of a programming language, a semantic error is thrown All raised standard exceptions must be handled in Python The standard exceptions are automatically imported into Python programs | The standard exceptions are automatically imported into Python programs |
| The object of a new class will have access to both methods, but the one from its own class will have precedence when invoked. This is called class method. | False |
| What will be the output of t[5]? Choices: IndexError NameError ValueError TypeError | IndexError |
| The name of the parent class is put in the parentheses in front of it, indicating the relation between the two. | True |
| To throw (or raise) an exception, use the delete keyword. | False |
| An exception is ____________. Choices: an object a special function a module a standard module | an object |
| Choose to throw an exception if a condition occurs. | True |
| Not a standard exception in Python. Choices: ValueError AssignmentError IOError NameError | AssignmentError |
| The self parameter is a reference to the current instance of the class. | True |
| Any member in a Python class can be accessed from outside the class environment. | True |
| A class in Python can be defined using the class keyword. | True |
| To throw (or raise) an exception, use the raise keyword. | True |
| Which of the following blocks will be executed whether an exception is thrown or not? Choices: finally else assert except | finally |
| You can modify the functionality of any base class method. | True |