- Which keyword is used to define a class in Python?
View Answer
Correct answer: A — class
- What will be printed?
1 python 2 class Eduinq: 3 pass 4 print(type(Eduinq)) View Answer
Correct answer: A — <class 'type'>
- Which of the following is used to create object of class?
View Answer
Correct answer: A — obj = Eduinq()
- What is the output of print(isinstance(5,int))?
View Answer
Correct answer: A — True
- Which of the following is used to define constructor in Python?
View Answer
Correct answer: A — init
- What will be printed?
1 python 2 class Eduinq: 3 def __init__(self): 4 print("Constructor") 5 Eduinq() View Answer
Correct answer: A — Constructor
- Which of the following is used to define instance method?
View Answer
Correct answer: A — def method(self):
- What is the output of print(Eduinq.name)?
View Answer
Correct answer: A — Eduinq
- Which of the following is used to define class variable?
View Answer
Correct answer: A — variable inside class but outside methods
- What will be printed?
1 python 2 class Eduinq: 3 x = 10 4 print(Eduinq.x) View Answer
Correct answer: A — 10
- Which of the following is used to access instance variable?
View Answer
Correct answer: D — Both A and C
- What is the output of print(isinstance(Eduinq(),Eduinq))?
View Answer
Correct answer: A — True
- Which of the following is used to define class method?
View Answer
Correct answer: A — @classmethod
- What will be printed?
1 python 2 class Eduinq: 3 @classmethod 4 def show(cls): 5 return "Class Method" 6 print(Eduinq.show()) View Answer
Correct answer: A — Class Method
- Which of the following is used to define static method?
View Answer
Correct answer: A — @staticmethod
- What is the output of print(type(Eduinq()))?
View Answer
Correct answer: A — <class 'main.Eduinq'>
- Which of the following is used to inherit class?
View Answer
Correct answer: A — class Child(Parent):
- What will be printed?
1 python 2 class Parent: 3 pass 4 class Child(Parent): 5 pass 6 print(issubclass(Child,Parent)) View Answer
Correct answer: A — True
- Which of the following is used to check object type?
View Answer
Correct answer: C — Both A and B
- What is the output of print(isinstance(Child(),Parent))?
View Answer
Correct answer: A — True
- Which of the following is used to access class variable?
View Answer
Correct answer: A — ClassName.variable
- What will be printed?
1 python 2 class Eduinq: 3 x = 10 4 def show(self): 5 return self.x 6 obj = Eduinq() 7 print(obj.show()) View Answer
Correct answer: A — 10
- Which of the following is used to define private variable?
View Answer
Correct answer: A — __variable
- What is the output of print(hasattr(Eduinq,"x")) if class Eduinq has variable x?
View Answer
Correct answer: A — True
- Which of the following is used to delete attribute?
View Answer
Correct answer: A — del obj.attr
- What will be printed?
1 python 2 class Eduinq: 3 def __init__(self,x): 4 self.x = x 5 obj = Eduinq(5) 6 print(obj.x) View Answer
Correct answer: A — 5
- Which of the following is used to define inheritance?
View Answer
Correct answer: A — class Child(Parent):
- What is the output of print(issubclass(Eduinq,object))?
View Answer
Correct answer: A — True
- Which of the following is used to override method?
View Answer
Correct answer: A — Define method with same name in child class
- What will be printed?
1 python 2 class Parent: 3 def show(self): 4 return "Parent" 5 class Child(Parent): 6 def show(self): 7 return "Child" 8 print(Child().show()) View Answer
Correct answer: A — Child
- Which of the following is used to access parent method?
View Answer
Correct answer: A — super().method()
- What is the output of print(super(Child,Child()).class)?
View Answer
Correct answer: A — <class 'super'>
- Which of the following is used to define multiple inheritance?
View Answer
Correct answer: A — class Child(Parent1,Parent2):
- What will be printed?
1 python 2 class A: 3 def show(self): 4 return "A" 5 class B: 6 def show(self): 7 return "B" 8 class C(A,B): 9 pass 10 print(C().show()) View Answer
Correct answer: A — A
- Which of the following is used to check method resolution order?
View Answer
Correct answer: A — ClassName.mro()
- What is the output of print(C.mro()) for class C(A,B)?
View Answer
Correct answer: A — [C,A,B,object]
- Which of the following is used to define abstract class?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 python 2 from abc import ABC,abstractmethod 3 class Eduinq(ABC): 4 @abstractmethod 5 def show(self): 6 pass 7 print(isinstance(Eduinq,ABC)) View Answer
Correct answer: A — True
- Which of the following is used to define polymorphism?
View Answer
Correct answer: A — Same method name, different behavior
- What is the output of print(len(dir(object)))?
View Answer
Correct answer: A — Number of default methods in object class
- Which of the following is used to define encapsulation?
View Answer
Correct answer: A — Restricting access to variables
- What will be printed?
1 python 2 class Eduinq: 3 def __init__(self): 4 self.__x = 10 5 obj = Eduinq() 6 print(hasattr(obj,"__x")) View Answer
Correct answer: A — False
- Which of the following is used to define dunder methods?
View Answer
Correct answer: A — init, str, repr
- What is the output of print(str(Eduinq())) if Eduinq has str defined?
View Answer
Correct answer: A — String returned by str
- Which of the following is used to define operator overloading?
View Answer
Correct answer: A — add, sub, mul
- What will be printed?
1 python 2 class Eduinq: 3 def __add__(self,other): 4 return "Added" 5 print(Eduinq()+Eduinq()) View Answer
Correct answer: A — Added
- Which of the following is used to define destructor?
View Answer
Correct answer: A — del
- What is the output of print(hasattr(Eduinq,"del"))?
View Answer
Correct answer: A — True
- Which of the following is used to define class inheritance chain?
View Answer
Correct answer: A — issubclass()
- What will be printed?
1 python 2 class Parent: 3 pass 4 class Child(Parent): 5 pass 6 print(issubclass(Child,Parent)) View Answer
Correct answer: A — True