A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

11. What is the output of the following code ?
class father:
    def __init__(self, param):
        self.o1 = param
 
class child(father):
    def __init__(self, param):
        self.o2 = param
 
>>>obj = child(22)
>>>print "%d %d" % (obj.o1, obj.o2)
a. None None
b. None 22
c. 22 None
d. Error is generated
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).Error is generated

12. What is the output of the following code ?
class tester:
    def __init__(self, id):
        self.id = str(id)
        id="224"
 
>>>temp = tester(12)
>>>print(temp.id)
a. 224
b. Error
c. 12
d. None
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).12

13. What is the output of the following code ?
>>>example = "snow world"
>>>print("%s" % example[4:7])
a. wo
b. world
c. sn
d. rl
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).wo

14. What is the output of the following code ?
>>>example = "snow world"
>>>example[3] = 's'
>>>print example
a. snow
b. snow world
c. Error
d. snos world
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Error

15. What is the output of the following code ?
>>>max("what are you")
a. error
b. u
c. t
d. y
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).y

16. Given a string example=”hello” what is the output of example.count(l)
a. 2
b. 1
c. None
d. 0
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).2

17. What is the output of the following code ?
>>>example = "helle"
>>>example.find("e")
a. Error
b. -1
c. 1
d. 0
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).1

18. What is the output of the following code ?
>>>example = "helle"
>>>example.rfind("e")
a. -1
b. 4
c. 3
d. 1
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).4

19. What is the output of the following code ?
>>>example="helloworld"
>>>example[::-1].startswith("d")
a. dlrowolleh
b. True
c. -1
d. None
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).True

20. To concatenate two strings to a third what statements are applicable ?
a. s3 = s1 . s2
b. s3 = s1.add(s2)
c. s3 = s1.__add__(s2)
d. s3 = s1 * s2
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).s3 = s1.__add__(s2)

Page 2 of 13