Advertisements
Advertisements
Question
Which of the following is the output of the following program?
class Student:
def __init__(self, name):
self.name=name
print (self.name)
S=Student(“Tamil”)
Options
Error
Tamil
name
self
MCQ
Solution
Tamil
shaalaa.com
Sample Programs to Illustrate Classes and Objects
Is there an error in this question or solution?
APPEARS IN
RELATED QUESTIONS
What is the output of the following program?
class Sample:
__num = 10
def disp(self):
print(self.__num)
S = Sample()
S.disp()
print(S.__num)
Find the error in the following program to get the given output?
class Fruits:
def __init__(self, f1, f2):
self.f1=f1
self.f2=f2
def display(self):
print("Fruit 1 = %s, Fruit 2 = %s" %(self.f1, self.f2))
F = Fruits ('Apple', 'Mango')
del F.display
F.display()
Output
Fruit 1 = Apple, Fruit 2 = Mango
What is the output of the following program?
class Greeting:
def __init__(self, name):
self.__name = name
def display(self):
print("Good Morning ", self.__name)
obj=Greeting('Bindu Madhavan')
obj.display()