Analyze nestle csr initiative plan focuses on society issues
This is a CSR project, and choose to nestle as our company Note: Please give answer on mentioned words (must add intext citation) and required
Answer the following Questions
1. What is it called when one class is derived from another single class?
1 Simple inheritance
2 Multiple inheritance
3 Multi-level inheritance
4 Single inheritance
5 None of these.
2. What does the following class definition portrays?
class Rect(Shape):
def init (self,x,y): Shape. init (self,x,y)
1 A single inheritance where class Rect inherits class Shape.
2 A single inheritance where class Shape inherits class Rect.
3 There is no inheritance.
4 None of these
3. What is it called when a derived class has got more than one base class?
1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these
4. Which of the given code segments will print the area of an object r1 of class Rect as 12 correctly?
1 class Shape:
def init (self, x,y): self. l=x
self. b=y def area(self):
return self. l * self. b
class Rect(Shape):
def init (self,x,y):
Shape. init (self,x,y) r1=Rect(3,4) print(“Area:”, r1.area())
2 class Shape:
def init (self, x,y): self. l=x
self. b=y def area(self):
return self. l * self. b
class Rect(Shape):
def init (self,x,y):
Shape. init (self,x,y) r1=rect(3,4) print(“Area:”, r1.l * r1.b)
3 Both 1 and 2
4 None of these
5. b=[2,6,8]. Of what type of variable is b an example?
1 string
2 tuple
3 list
4 None of these
6. Which of the given code segments will print the area of an object s of class Square as 144 correctly?
1 class Square:
def init (self, a): self. a=a
s=Square(12)
print(s._Square a * s._Square a)
2 class Square:
def init (self, a): self. a=a
s=Square(12)
print(s. a * s a)
3 class Square:
def init (self, a): self. a=a
s=Square(12)
print(s.Square a * s.Square a)
4 None of these
7. In the following code n1 is an object of the derived class Num1. What is the output?
class Num:
def init (self): self.a=2 self.b=3
def calc(self):
return self.a*self.b class Num1(Num):
def init (self): Num. init (self)
def calc(self):
return self.a+self.b n1=Num1()
print(n1.calc())
1 2
2 3
3 5
4 6
8. In the following code n1 is an object of the derived class Num1. What is the output?
class Num:
def init (self): self.a=2
self.b=3
def calc(self): return self.a*self.b
class Num1(Num):
def init (self): Num. init (self)
def calc(self): print(Num.calc(self),end=
‘ ‘)
print(self.a+self.b) n1=Num1()
n1.calc()
1 2 3
2 3 2
3 6 5
4 5 6
9. What is it called when a class inherits a derived class?
1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these
10. What type of inheritance does the following code snippet demonstrate?
class A:
pass class B(A):
pass class C(B):
pass
1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these
11. What type of inheritance does the following code snippet demonstrate?
class A:
pass class B:
pass class C(A,B):
pass
1 Multiple inheritance
2 Multi-level inheritance
3 Single inheritance
4 None of these
12. What is the output of the following code?
class A:
def display(self): print(“Calling method of Class A”)
class B():
def display(self): print(“Calling method of Class B”)
class C(B,A): pass
obj=C()
obj.display()
1 Calling method of Class A
2 Calling method of Class B
3 pass
4 None of these
13. Which statement is false?
1 For data that are owned by individual objects of a class, you must use class variables.
2 A derived class can have more than one parent.
3 You can add, subtract, multiply and divide class instances.
4 To maintain data that is held in common by all objects of a class, you should use class variables.
14. Which of the given code fragments facilitate the addition of two instances of class A?
1 class A:
def init (self): self.x=20;
def add(self, other): return self.x+other.x
a1=A()
a2=A()
a3=a1+a2
2 class A:
def init (self): self.x=20;
a1=A()
a2=A()
a3=a1+a2
3 class A:
def init (self): self.x=20;
def add (self, other): return self.x+other.x
a1=A()
a2=A()
a3=a1+a2
4 All the above
15. Which method should be implemented into the class when two instances of a class are compared by using the == operator?
1 isequal
2 equal
3 eq
4 None of these
16. What is the output of the following code?
class Subject(object):
def init (self,mark): self.mark=mark
def set_mark(self, mark): if mark < 0:
self.mark = 0 elif mark > 100:
self.mark = 100 else:
self.mark = mark def get_mark(self):
return self.mark
m=property(get_mark,set_mark) s=Subject(70)
s.m=102
print(s.m)
1 70
2 102
3 100
4 None of these
17. What is a class called that implements special methods like set , get or delete ?
1 Super class
2 descriptor
3 Sub-class
4 None of these
18. What do you call a class that implements only the get method for an object?
1 non-data-descriptor
2 data descriptor
3 getter class
4 None of these
19. What is a class called that implements the set method for an object?
1 non-data-descriptor
2 data descriptor
3 setter class
4 None of these
20. What is the output of the following code?
class Desc(object): def init (self):
self._name = ”
def
get (self,instance,owner): return self._name
def
set (self,instance,value): self._name =
value.title()
class Person(object): nameObj = Desc()
p = Person()
p.nameObj = ‘Mr. daniel johnson’ print(p.nameObj)
1 Mr. daniel johnson
2 Mr
3 Mr. Daniel Johnson
4 None of these