What is the output of the following code ?
class Foo:
X = 10
def hello(self):
self.X = 20
print(Foo.X)
What is the output of the following code ?
class Foo:
X = 10
def hello(self):
self.X = 20
f = Foo()
print(Foo.X, f.X)
What is the output of the following code ?
class Foo:
X = 10
def hello(self):
self.X = 20
f = Foo()
f.hello()
print(Foo.X, f.X)
What is the output of the following code ?
class Foo:
X = 10
def hello(self):
self.X = 20
f = Foo()
f.hello()
p = Foo()
print(Foo.X, f.X, p.X)
What is the output of the following code ?
class Foo:
X = 10
f = Foo()
Foo.X = 30
p = Foo()
print(Foo.X, f.X, p.X)
What is the output of the following code ?
class MyClass:
def __init__(self):
self.__a = 1
obj = MyClass()
print(obj.__a)
Which of the following is a attribute of the instance obj and also private.which can not be retrieved by obj.attributname ?
class MyClass:
def __init__(self):
__a = 1
self.__b = 1
self.__c__ = 1
__d__ = 1
obj = MyClass()
What is the output of the following code ?
class MyClass:
def __init__(self):
self.__b = 1
def display(self):
print(self.__b)
obj = MyClass()
obj.display()
What is the output of the following code ?
class MyClass:
def __init__(self):
self.__a = 1
obj = MyClass()
print(obj._MyClass__a)
What is the output of the following code ?
class MyClass:
def __init__(self):
self._a = 1
obj = MyClass()
print(obj._MyClass_a)