adplus-dvertising

Welcome to the Classes,Objects and OOPS concepts MCQs Page

Dive deep into the fascinating world of Classes,Objects and OOPS concepts with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Classes,Objects and OOPS concepts, a crucial aspect of Python. In this section, you will encounter a diverse range of MCQs that cover various aspects of Classes,Objects and OOPS concepts, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Python.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Classes,Objects and OOPS concepts. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Python.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Classes,Objects and OOPS concepts. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Classes,Objects and OOPS concepts MCQs | Page 9 of 13

Q81.
What is the output of the following code?
 class Demo:
    def __init__(self):
        pass
 
    def test(self):
        print(__name__)
 
obj = Demo()
obj.test()
Discuss
Answer: (b).__main__
Q82.
What is the output of the following code?
>>> class demo():
	def __repr__(self):
		return '__repr__ built-in function called'
	def __str__(self):
		return '__str__ built-in function called'
>>> s=demo()
>>> s
Discuss
Answer: (d).__repr__ called
Q83.
What is the output of the following code?
>>> class demo():
	def __repr__(self):
		return '__repr__ built-in function called'
	def __str__(self):
		return '__str__  built-in function called'
>>> s=demo()
>>> print(s)
Discuss
Answer: (a).__str__ called
Discuss
Answer: (c).To check if an attribute exists or not
Q85.
What is the output of the following piece of 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: (a).Error as age isn’t defined
Discuss
Answer: (b).To delete an attribute
Q87.
__del__ method is used to destroy instances of a class. True or False?
Discuss
Answer: (a).True
Q88.
What is the output of the following piece of code?
class stud:
   ‘Base class for all students’
   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)
print(student.__doc__)
Discuss
Answer: (d).Base class for all students
Q89.
What does print(Test.__name__) display (assuming Test is the name of the class) ?
Discuss
Answer: (c).Test
Q90.
When defining a subclass in Python that is meant to serve as a subtype, the subtype Python keyword is used. Is the statement true or false?
Discuss
Answer: (b).False

Suggested Topics

Are you eager to expand your knowledge beyond Python? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!