class Demo:
def __init__(self):
self.a = 1
self.__b = 1
def get(self):
return self.__b
obj = Demo()
obj.a=45
print(obj.a)Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
87
Questions
4/5
Page
Pick an option on a question to see the right answer and solution.
class Demo:
def __init__(self):
self.a = 1
self.__b = 1
def get(self):
return self.__b
obj = Demo()
obj.a=45
print(obj.a)Select an option to see the answer and solution.
class fruits:
def __init__(self):
self.price = 100
self.__bags = 5
def display(self):
print(self.__bags)
obj=fruits()
obj.display()Select an option to see the answer and solution.
Select an option to see the answer and solution.
class Demo:
def __init__(self):
self.a = 1
self.__b = 1
def get(self):
return self.__b
obj = Demo()
print(obj.get())Select an option to see the answer and solution.
class A:
def __init__(self):
self.multiply(15)
print(self.i)
def multiply(self, i):
self.i = 4 * i;
class B(A):
def __init__(self):
super().__init__()
def multiply(self, i):
self.i = 2 * i;
obj = B()Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
class A:
def __init__(self):
self.multiply(15)
def multiply(self, i):
self.i = 4 * i;
class B(A):
def __init__(self):
super().__init__()
print(self.i)
def multiply(self, i):
self.i = 2 * i;
obj = B()Select an option to see the answer and solution.
Select an option to see the answer and solution.
class A():
def disp(self):
print("A disp()")
class B(A):
pass
obj = B()
obj.disp()Select an option to see the answer and solution.
Select an option to see the answer and solution.
class Test:
def __init__(self):
self.x = 0
class Derived_Test(Test):
def __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.
Select an option to see the answer and solution.
class Demo:
def __new__(self):
self.__init__(self)
print("Demo's __new__() invoked")
def __init__(self):
print("Demo's __init__() invoked")
class Derived_Demo(Demo):
def __new__(self):
print("Derived_Demo's __new__() invoked")
def __init__(self):
print("Derived_Demo's __init__() invoked")
def main():
obj1 = Derived_Demo()
obj2 = Demo()
main()Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
class A:
def one(self):
return self.two()
def two(self):
return 'A'
class B(A):
def two(self):
return 'B'
obj2=B()
print(obj2.two())Select an option to see the answer and solution.
class student:
def __init__(self):
self.marks = 97
self.__cgpa = 8.7
def display(self):
print(self.marks)
obj=student()
print(obj._student__cgpa)Select an option to see the answer and solution.
class A:
def test1(self):
print(" test of A called ")
class B(A):
def test(self):
print(" test of B called ")
class C(A):
def test(self):
print(" test of C called ")
class D(B,C):
def test2(self):
print(" test of D called ")
obj=D()
obj.test()Select an option to see the answer and solution.