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 12 of 13

Q111.
What is the output of the following piece of code?
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())
Discuss
Answer: (d).B
Discuss
Answer: (a).A non-private method in a superclass can be overridden
Q113.
The purpose of name mangling is to avoid unintentional access of private class members. True or False?
Discuss
Answer: (a).True
Q114.
What is the output of the following code?
class fruits:
    def __init__(self):
        self.price = 100
        self.__bags = 5
    def display(self):
        print(self.__bags)
obj=fruits()
obj.display()
Discuss
Answer: (c).The program runs fine and 5 is printed
Q115.
What is the output of the following code?
 class student:
    def __init__(self):
        self.marks = 97
        self.__cgpa = 8.7
    def display(self):
        print(self.marks)
obj=student()
print(obj._student__cgpa)
Discuss
Answer: (a).The program runs fine and 8.7 is printed
Discuss
Answer: (c).They can be accessed by name mangling method
Q117.
What is the output of the following piece of code?
class objects:
    def __init__(self):
        self.colour = None
        self._shape = "Circle" 
 
    def display(self, s):
        self._shape = s
obj=objects()
print(obj._objects_shape)
Discuss
Answer: (b).Error because the member shape is a protected member
Q118.
What is the output of the code shown below?
x=10
y=8
assert x>y, 'X too small'
Discuss
Answer: (c).No output
Q119.
What is the output of the code shown below?
#generator
def f(x):
    yield x+1
g=f(8)
print(next(g))
Discuss
Answer: (b).9
Q120.
What is the output of the code shown below?
def f(x):
    yield x+1
    print("test")
    yield x+2
g=f(9)
Discuss
Answer: (d).No output

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!