Questão 1
Questão
Which of the following represents a distinctly identifiable entity in the real world?
Responda
-
A class
-
An object
-
A method
-
A data field
Questão 2
Questão
Which of the following represents a template, blueprint, or contract that defines objects of the same type?
Responda
-
A class
-
An object
-
A method
-
A data field
Questão 3
Questão
Which of the following keywords mark the beginning of the class definition?
Responda
-
def
-
return
-
class
-
All of the above.
Questão 4
Questão
Which of the following is required to create a new instance of the class?
Responda
-
A constructor
-
A class
-
A value-returning method
-
A None method
Questão 5
Questão
Which of the following statements is most accurate for the declaration x = Circle()?
Responda
-
x contains an int value.
-
x contains an object of the Circle type.
-
x contains a reference to a Circle object.
-
You can assign an int value to x.
Questão 6
Questão
What will be the output of the following code snippet?
class Sales:
def __init__(self, id):
self.id = id
id = 100
val = Sales(123)
print (val.id)
Questão 7
Questão
Which of the following statements are correct?
Responda
-
A reference variable is an object.
-
A reference variable refers to an object.
-
An object may contain other objects.
-
An object can contain the references to other objects.
Questão 8
Questão
What will be the output of the following?
s = "\t\tWelcome\n"
print(s.strip())
Responda
-
\t\tWelcome\n
-
Welcome\n
-
\t\tWELCOME
-
Welcome
Questão 9
Questão
What will be the output of the following code snippet?
class Person:
def __init__(self, id):
self.id = id
sam = Person(100)
sam.__dict__['age'] = 49
print (sam.age + len(sam.__dict__))
Questão 10
Questão
Which of the following can be used to invoke the __init__ method in B from A, where A is a subclass of B?
Responda
-
super().__init__()
-
super().__init__(self)
-
B.__init__()
-
B.__init__(self)
Questão 11
Questão
Which of the following statements are correct about the given code snippet?
class A:
def __init__(self, i = 0):
self.i = i
class B(A):
def __init__(self, j = 0):
self.j = j
def main():
b = B()
print(b.i)
print(b.j)
main()
Responda
-
Class B inherits A, but the data field “i” in A is not inherited.
-
Class B inherits A, thus automatically inherits all data fields in A.
-
When you create an object of B, you have to pass an argument such as B(5).
-
The data field “j” cannot be accessed by object b.
Questão 12
Questão
Which of the following statements is true ?
Responda
-
By default, the __new__() method invokes the __init__ method.
-
The __new__() method is defined in the object class.
-
The __init__() method is defined in the object class.
-
The __str__() method is defined in the object class.
-
The __eq__(other) method is defined in the object class.
Questão 13
Questão
What will be the output of the following code snippet?
class A:
def __init__(self):
self.calcI(30)
print("i from A is", self.i)
def calcI(self, i):
self.i = 2 * i;
class B(A):
def __init__(self):
super().__init__()
def calcI(self, i):
self.i = 3 * i;
b = B()
Responda
-
The __init__ method of only class B gets invoked.
-
The __init__ method of class A gets invoked and it displays “i from A is 0”.
-
The __init__ method of class A gets invoked and it displays “i from A is 60”.
-
The __init__ method of class A gets invoked and it displays “i from A is 90”.
Questão 14
Questão
What will be the output of the following code snippet?
class A:
def __init__(self):
self.calcI(30)
def calcI(self, i):
self.i = 2 * i;
class B(A):
def __init__(self):
super().__init__()
print("i from B is", self.i)
def calcI(self, i):
self.i = 3 * i;
b = B()
Responda
-
The __init__ method of only class B gets invoked.
-
The __init__ method of class A gets invoked and it displays “i from B is 0”.
-
The __init__ method of class A gets invoked and it displays “i from B is 60”.
-
The __init__ method of class A gets invoked and it displays “i from B is 90”.
Questão 15
Questão
Which of the following statements can be used to check, whether an object “obj” is an instance of class A or not?
Responda
-
obj.isinstance(A)
-
A.isinstance(obj)
-
isinstance(obj, A)
-
isinstance(A, obj)
Questão 16
Questão
What relationship correctly fits for University and Professor?
Responda
-
association
-
composition
-
inheritance
-
All of the above
Questão 17
Questão
What relationship is suited for Course and Faculty?
Responda
-
association
-
composition
-
inheritance
-
None of the above
Questão 18
Questão
What relationship is best suited for Employee and Person?
Responda
-
association
-
composition
-
inheritance
-
None of the above