31. Which of the following is not a type of inheritance?
a. Single-level
b. Double-level
c. Multiple
d. Multi-level
View Answer
Ans. b
Explanation : There is no inheritance known as Double-level
32. The following values are to be stored in a hash table (arriving in the order shown) using the hash function, h(k)= k%5.
81, 20, 34, 42, 21, 45
Assume that the hash values are stored in ascending order. Identify whether
collision will occur while mapping the values using the hash function.
a. Collision will occur at position 0,1
b. Collision will occur at position 0
c. Collision will occur at position 1
d. Collision will occur at position 3
View Answer
Ans. a
Explanation : Hash Values are
h(k) : 1, 0, 4, 2, 1, 0
Collision will occur at position 0,1
33. Consider the following algorithm of bubble sort :
def bubble_sort(input_list):
num = len(input_list)
for index1 in range(num):
for index2 in range(0, num-index1-1):
if input_list[index2] > input_list[index2+1]:
input_list[index2], input_list[index2+1] = input_list[index2+1], input_list[index2]
input_list = [4,10,2,7,1,8]
bubble_sort(input_list)
What will be the content of input_list after third pass ?
a. [2,4,1,7,8,10]
b. [2,1,4,7,8,10]
c. [2,4,8,7,1,10]
d. [1,2,4,7,8,10]
View Answer
Ans. d
Explanation : Dry run the given algorithm to cross-check
34. Find the output :
class test:
def __init__(self):
print("Hello World")
def __init__(self):
print ("Bye World")
obj=test()
a. Hello World
b. Compilation Error
c. Bye World
d. Ambiguity
View Answer
Ans. c
Explanation : If multiple init methods are written for the same class, then the latest one overwrites all the previous constructors.
35. Find the output :
int = 1
def randommethod():
global int
for i in (1, 2, 3):
int += 1
randommethod()
print(int)
a. Compile Time Error
b. 1
c. Type Error
d. 4
View Answer
Ans. d
Explanation : For i=1,i=2,i=3, int gets incremented