Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Type atleast 3 characters
Popular Searches
Trending Pages
Notifications Mark All Read
No New notification
InfyTQ Menu9>
PREPINSTA PRIME
Get Hiring Updates right in your inbox from PrepInsta
Question 1
class
constructor
User-defined functions
In-built functions
Start
Question 2
An object
An operator
A class
A method
Question 3
class pizza: def __init__(self, money): self.money = money obj=pizza(99) obj.amount=4 obj.total=2 print(obj.amount+len(obj.__dict__))
6
7
99
105
Question 4
class test(): def __repr__(self): return 'This is called' def __str__(self): return 'No! This is called' s=test() print(s)
This is called
Nothing is printed
Error
No! This is called
Question 5
access the attribute of the object
delete an attribute
check if an attribute exists or not
set an attribute
Question 6
class Engineer: 'Base class for all students' def __init__(self, id_no, score): self.id_no = id_no self.score = score def display (self): print("Roll no : ", self.id_no, ", Grade: ", self.score) print(Engineer.__doc__)
None
Nothisg is printed
Base class for all students
Question 7
class Demo: def __init__(self): self.x = 0 class Derived_Demo(Demo): def __init__(self): self.y = 1 def main(): b = Derived_Demo() print(b.x,b.y) main()
0 1
1 0
0 0
Question 8
class prep(): pass class insta(): pass class python(prep, insta): pass
Multi-level inheritance
Multiple inheritance
Hierarchical inheritance
Single-level inheritance
Question 9
A non-private method in a superclass can be overridden
A derived class is a subset of a superclass
The value of a private variable in the superclass can be changed in the subclass
When invoking the constructor from a subclass, the constructor of the superclass is automatically invoked
Question 10
class D: def __init__(self,x): self.x = x def count(self,x): self.x = self.x+1 class C(D): def __init__(self, y=0): D.__init__(self, 5) self.y = y def count(self): self.y += 1 def main(): obj = C() obj.count() print(obj.x, obj.y) main()
5 0
5 1
Please login to report