Which of the following is the most suitable definition for encapsulation?
Select an option to see the answer and solution.
What is the purpose of the super() function in object-oriented programming?
Select an option to see the answer and solution.
What is the purpose of the super() function in object-oriented programming?
Select an option to see the answer and solution.
The purpose of name mangling is to avoid unintentional access of private class members.
Select an option to see the answer and solution.
Which of these is a private data field?
def Demo:
def __init__(self):
__a = 1
self.__b = 1
self.__c__ = 1
__d__= 1
Select an option to see the answer and solution.
What will be the output of the following Python code?
class A:
def __init__(self,x=3):
self._x = x
class B(A):
def __init__(self):
super().__init__(5)
def display(self):
print(self._x)
def main():
obj = B()
obj.display()
main()
Select an option to see the answer and solution.
Private members of a class cannot be accessed.
Select an option to see the answer and solution.
What is the purpose of the @property decorator in object-oriented programming?
Select an option to see the answer and solution.
What is the purpose of using encapsulation in object-oriented programming?
Select an option to see the answer and solution.
How is polymorphism implemented in object-oriented programming?
Select an option to see the answer and solution.
What is the primary purpose of a constructor in object-oriented programming?
Select an option to see the answer and solution.
What will be the output of the following Python code?
class A:
def __init__(self, x= 1):
self.x = x
class der(A):
def __init__(self,y = 2):
super().__init__()
self.y = y
def main():
obj = der()
print(obj.x, obj.y)
main()
Select an option to see the answer and solution.
What will be the output of the following Python code?
class Demo:
def __check(self):
return " Demo's check "
def display(self):
print(self.check())
class Demo_Derived(Demo):
def __check(self):
return " Derived's check "
Demo().display()
Demo_Derived().display()
Select an option to see the answer and solution.
Which of the following is false about protected class members?
Select an option to see the answer and solution.
Which of these is not a fundamental features of OOP?
Select an option to see the answer and solution.
What is the main advantage of using encapsulation in object-oriented programming?
Select an option to see the answer and solution.
What will be the output of the following Python code?
class A:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return 1
def __eq__(self, other):
return self.x * self.y == other.x * other.y
obj1 = A(5, 2)
obj2 = A(2, 5)
print(obj1 == obj2)
Select an option to see the answer and solution.
All subclasses are a subtype in object-oriented programming.
Select an option to see the answer and solution.
What will be the output of the following Python code?
class Test:
def __init__(self):
self.x = 0
class Derived_Test(Test):
def __init__(self):
Test.__init__(self)
self.y = 1
def main():
b = Derived_Test()
print(b.x,b.y)
main()
Select an option to see the answer and solution.
Which principle of OOP allows a class to provide a specific implementation of a method that is already defined in its parent class?
Select an option to see the answer and solution.