ExamVeda
Login
Home
31
What is the purpose of the @staticmethod decorator in Python classes?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
32
Is the following Python code valid?
class B(object):
  def first(self):
    print("First method called")
  def second():
    print("Second method called")
ob = B()
B.first(ob)
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
33
Which function overloads the == operator?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
34
What will be the output of the following Python code?
class stud:
   def __init__(self, roll_no, grade):
      self.roll_no = roll_no
      self.grade = grade
   def display (self):
      print("Roll no : ", self.roll_no,  ", Grade: ", self.grade)
stud1 = stud(34, 'S')
stud1.age=7
print(hasattr(stud1, 'age'))
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
35
What does print(Test.__name__) display (assuming Test is the name of the class)?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
36
What is a constructor in Python classes?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
37
Which of the following Python code will print True?
a = foo(2)
b = foo(3)
print(a < b)
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
38
Which function overloads the + operator?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
39
What is the purpose of the @classmethod decorator in Python classes?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
40
What is the output of the following code:
class Parent:
def init(self):
print('Parent constructor')
class Child(Parent):
def init(self):
print('Child constructor')
obj = Child()
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board