0% found this document useful (0 votes)
47 views1 page

Chapter-5 MCQs

The document contains 22 multiple choice questions related to object-oriented programming concepts in Python. The questions cover topics like class declaration, object creation, methods, constructors, private members, inheritance, and more.

Uploaded by

rahul ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

Chapter-5 MCQs

The document contains 22 multiple choice questions related to object-oriented programming concepts in Python. The questions cover topics like class declaration, object creation, methods, constructors, private members, inheritance, and more.

Uploaded by

rahul ma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Sr No Question A B C D ANSWER

1 Choose correct way to create a class Class Classname: class classname: Class classname() class classname() B
2 How to create object of class "student" s1 s1=new student s1=student() s1=student C
How many objects and reference variables are there for
the given Python code?
class A:
0 1 2 3 B
print("HELLO")
A
3 obj=A()
4 In python, what is the method inside a class? attibute object argument function D
5 Private members of a class cannot be accessed TRUE FALSE B
. _____ represents an entity in the real world with its
identity A method An object A class An operator B
6 and behavior.
What is the output of foll code?
class A:
def show(self):
HELLO None HELLO HELLO Error D
print("HELLO")
obj=A()
7 A.show()
The attribute can be deleted using ____________
Delete DEL del delete C
8 keyword
9 How to decalre data member as pivate in python? single underscoe double underscore PRIVATE keywod private keyword B
10 The __init__() function is a _________ constructor destructor method initialized method A
Is that true __init__() function automatically called when an
TRUE FALSE A
11 object is created? *
Is that true __init__() function automatically called when
we called using object called using init() an object is created called using run() C
12 __________________________
13 Constructor overloading is allowed in python. TRUE FALSE B
14 __del__() is _________
Is this code is valid in python or not
class A: yes no may be A
15 pass
What is the output?
class A:
def __init__(self):
Constructo Constructo Constructo Destructor
print("Constructo")
Constructo Constructo Destructor Destructor
def __del__(self): B
Destructor Destructor Constructo Constructo
print("Destructor")
Destructor Destructor
t1=A()
t1.__init__()
16 t1.__del__()
_____________ is the mechanism which does not allow
Data Hiding Data Abstraction Data Validation Data Encapsulation A
17 to access the attributes outside the class.
The class from which the child class inherits is called
child class parent class subclass Any class B
18 ________
Which keyword is used to access members of the base
self pass super assert C
19 class?
what is teh output?
class A:
def __init__(self):
self.count=10 0 10 11 Error D
self.count=count+1
a=A()
20 print(a.count)
what is the output class
A:
def __init__(self,a,r):
self.age=a 18
12 18 0 Error A
self.roll=r 12
obj=A(18,12)
print(obj.age)
21 print(obj.roll)
what is the output
class A:
def __init__(self,count=100):
self.count=count 100 101 100 101
A
obj1=A() 101 101 100 100
obj2=A(101)
print(obj1.count)
22 print(obj2.count)

You might also like