Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

D. Null Operator

Download as pdf or txt
Download as pdf or txt
You are on page 1of 49

COMPUTER PROGRAMING:

1) Null function is also known as ___________.

A. Anonymous Function
B. Generic Function
C. Void Function
D. Null Operator

2) A complete binary tree has a property that the value at each node is at least as large as the values at its
children nodes. What is this binary tree known as?

A. Binary Search Tree


B. AVL Tree
C. Completely Balanced Tree
D. Heap

3) Which of the following is NOT a data type?

A. Integer
B. Character
C. Boolean
D. Array

4) Which of the following sorting algorithms yields approximately the same worst-case and average-case running
time behavior in O(n long)?

A. Bubble sort and Selection sort


B. Heap sort and Merge sort
C. Quick sort and Radix sort
D. Tree sort and Median-of-3 Quick sort

5) A programmer is making a database of animals in a zoo along with their properties. The possible animals are
dog. Lion and zebra each one has attributes as herbivorous. Color and nocturnal. The programmer uses the object-
oriented programming paradigm for this. How will the system be conceptualized?

A. Class: Animal; objects: dog, lion and zebra: data members: herbivorous, color and nocturnal
B. Class: Animal; objects: herbivorous, color and nocturnal: data members: dog lion and Zebra
C. Classes: dog lion and zebra: objects: Animal; data members; herbivorous, color and nocturnal
D. Nome of the above

6) A stack is implemented as a linear array A[0…N-1] A programmer writes the function given below to
pop out an element from the stack
Function POP ( top, N)

if (X)

top = top -1

else

“Print Underflow”

return top

Which of the following should substitute the condition”X”?

A. top<N-1
B. top<N
C. top>1
D. top>= 0

7) A queue is implemented as a singly linked-list. Each node has an element and a pointer to another node. The
Rear and the Front contain the addresses of the rear and the front nodes, respectively. What can be inferred about
the linked list if the condition (rear isequal front) is true?

A. It has no elements
B. It has one element
C. There is an error
D. None of the above

8) Consider the code given below. Assume that “a” and “b” are passed reference. What will the output of the
program be when the function calculate() is executed?

function modify(b,a)

{
return a –b

function calculate()

integer a = 5, b = 12, c

c = modify(a,b):

print c

A. 7
B. -7
C. 8
D. Error

Passage

functionmyfunc()

constant integer i=5

if (i> 3)

print “i am smali”

if ( i-- > 5 )

print “i am iarge”

eise print “i am different”

A pseudo-coed is used which is self explanatory.

9) What will be the output of the given code?

A. I am small
B. I am small am large
C. I am small am different
D. This code will generate an error

10) A librarian has to rearrange the library books on a shelf in a proper order at the end of each day. Which of the
following sorting techniques should be the librarian’s ideal choice?

A. Bubble sort
B. Insertion sort
C. Selection sort
D. Heap sort

11) A tree has 5 levels and each node has either 4 or no children. All nodes on the same level have the same
number of children. How many nodes are there in the tree?

A. 341
B. 256
C. 1024
D. None of the above

12) Why is an algorithm designer concerned primarily about the run time and not the compile time while
calculating time complexity of an algorithm?

A. Run time is always more than the compile time.


B. Compile time is always more than the run time.
C. Compile time is a function of run time.
D. A program needs to be compiled once but can be run several times.

13. For which of the following is the stack implementation useful?

A. Radix search
B. Breadth fist search
C. Recursion
D. None of the above

14. Passage

Function print_me(integer n) // Statement 1

if ( n < 1 ) return // Statement 2


print n // Statement 3
print_me(n-1) //Statement 4
}

A pseudo-code is used which is self explanatory,


// in pseudo code refers to comment
Pooja has written the following code to print numbers from 0 to n in reverse order using the recursive
approach. Find if there exists any error in the given code.
A. Statement 1
B. Statement 2
C. Statement 3
D. There is no error

15. How can a call to an overloaded function be ambiguous?


A. The name of the function might have been misspelled
B. There might be two or more functions with the same name
C. There might be two or more functions with equally appropriate signatures
D. None of the above

16. What will the output of the following pseudocode statements be?
(Note: Assume that when two data types are processed through an operator. The answer maintains the same data
type as that of input. Also, all data types have enough range to accommodate any number. If two different data
types are operated upon, the result assumes the data type that is more expressive.)
Integer a = 456, b, c, d = 10
b = a/b
c=a–b
Print c
A. 410
B. 410.4
C. 411.4
D. 411

17. Passage
while (j<=3*i)
{
print j
print blank space
j=j+3
}
print end-of-line //takes the cursor to the next line
i=i+1
}

A. 0
03
B. 0 3
036
C. 0 3
036
0 3 69
D. 0 3 6
0369
036912

18. What does the following function do?


function operation (int a, int b)
{
if (a>b)
{ retum operation(b, a) }
else
{ retum a: }
}
A. Always returns the first parameter
B. Returns the min of (a,b)
C. Returns the max of (a,b)
D. Loops forever

19. What is the average time required to perform a successful sequential search for an element in an array
A(1: n)?

A. (n+1)/2
B. log2n
C. n(n+1)/2
D.
n2

20. How are protected members of a base class accessed in the derived class when inherited privately in
C++?
A. Privately
B. Publicly
C. Protectedly
D. Not inherited

21. How many nodes does a full binary tree with n” non-leaf nodes contain?
A. log n
B. n + 1
C. 2n + 1
D. 2n

22. A programmer mistakenly writes “gor” instead of the keyword “for” used in loops, while writing a
program in C++. What will this result in?
A. The code would not compile.
B. The code would give an error while execution.
C. The code may work for some inputs and not for the others
D. The code would not create any problem.

23. Which of the following options is an exception to being a part of composite date types?
A. Union
B. Array
C. Structure
D. Stack

24. Q is an empty queue. The following operations are done on it:


ADD 5
ADD 7
ADD 46
DELETE
ADD 13
DELETE

25. Which characteristic of data does a binary search use and a linear search does not?
A. Order of the list
B. Length of the list
C. Maximum value of the list
D. None of the above

26. A sorting algorithm iteratively traverses through a list to exchange the first element with any element less than it. It
then repeats with a new first element. What is this sorting algorithm called?
A. Insertion sort
B. Selection sort
C. Heap sort
D. Quick sort

Paper-2
27. In which of the following methods is sorting NOT possible?
A. Insertion
B. Selection
C. Exchange
Deletion
28. Sruti is making a questionnaire of True-False question. She wants to define a data-type which stores the
response of the candidate for the question. What is the most suited data type for this purpose?
a. Integer B. Boolean c. float d. character

29. Parthiv has included several classes and their subjects in his project. Now he wants to use something that will
hold all these objects (of different classes). Which of the following options provides him with the best iterative?
A. Store them in database B. Final class C. Generic class D. Anonymous class

30. Shasi wants to make a program to print the sum of the first 10 multiples of 5. She writes the following program,
where statement 5 is missing.
integer i=0
integer sum=0
while ( i<= 50)
{
sum =sum+1
– – MISSING STATEMENT – –
}
print sum
Which of the following options will you use for statement 5?
A. i = 5 B. i = 5 *I C. i = i + 1 D. i = i + 5

31. Ravi is writing a program in C++. C++ uses the ‘for’ keyword for loops. Due to distraction Ravi writes ‘gor’
instead of ‘for’. What will this result to?
A. The code will not compile
B. The code will give an error while in execution
C. The code may work for some inputs and not for others
D. It will create no problems.

32. What is implied by the argument of a function?


A. Variables passed to it when it is called
B. The value is returns on execution
C. The execution code inside it
D. Its return type

33.Which of the following statements is true regarding the sorting and searching algorithms?
A. Linear searching is faster than the most efficient sorting algorithm
B. Linear searching is slower than the most efficient sorting algorithm
C. Linear searching and the most efficient sorting algorithm take up almost same time
D. Their complexities cannot be compared

34. What is the space complexity of a program?


A. Amount of hard-disk space required to store the program
B. Amount of hard-disk space required to compile the program
C. Amount of memory required by the program to run
D. Amount of memory required for the program to compile

35. Srishti writes a program to find an element in the array A[5] with the following elements in order: 8 30 40 45 70.
She runs the program to find a number X. Xis found in the first iteration of binary search. What is the value of X?
Choose the correct answer
A. 40 B. 8 C. 70 D. 30

36. Saloni writes the code for a function that takes as input n, an even integer and calculates the sum of 1st n
natural numbers
function sum (n)
{
if(n equals 2)
return 2
else
return ( n+ sum( n-1))
}
She then calls the function by the statement, sum(30). How many times will the function sum be called to
compute this sum? Choose the correct answer?
A. 1 B. 30 C. 15 D. 16

37. Shalini wants to programme to print the largest number out of 3 inputted numbers. She writes the
following programme
Int number 1, number 2, number 3, temp;
Input number 1, number 2, number 3;
If ( number 1 > number 2)
Temp = number 1
Else
Temp= number 2
End if
If ( ??) // statement 1
Temp = number 3
End if
Print temp
Fill in the ??in statement 1 ? Choose the correct answer?

A. Number 3> number 2 B. Number 3> temp C. Number 3< temp D. Number 3> number 1

44. How many pointers will have to be changed when a new node is to be added in a linear linked list in the
middle?
A. 0 B. 1 C. 2 D. All the pointers will be changed

45. A variable cannot be used? Choose the correct answer


A. Before it is declared B.After it is declared C. In the function it is declared in D. Can always be used

46. In which area of a class are data and function directly accessible outside the class? Choose the correct
answer
A. Public B. Private C. Protected D. None

47. Which of the following options is true regarding inheritance in Object Oriented Programming ? Choose
the correct answer?
A. There is reduced interaction with the hardware
B. A class may are may not have any object
C. Two are more functions can have the same name and number and type of arguments in a program
D. Class- object relation can be changed at run time
E. All of the above
48. Every element of a data structure has an address and a key associated with it. A search mechanism deals
with two or more values assigned to the same address by using the key. What is this search mechanism?
A. Linear search B. Selection search C. Hash coded search D. Binary search E. None of this

49. Which of the following abstract data types can be used to represent many – to- many relations?
A. Tree B. Stack C. Graph D. Queue

50. Pragya sells footballs. She has a large container to store footballs which is closed from below. Footballs
are piled one on top of the other in the box. When new balls are supplied, Pragya puts the balls in the box
from the top. When a customer buys a ball, she delivers the ball at the top of the pile to the customer. Each
ball has a code. She wants to store the ball codes in the data structure to keep track of her inventory. What
data structure should she use? Choose the correct answer?
A. Queue B. Stack C. Array D. Graph

51. The algorithm design technique used in quick sort algorithm is? Choose the correct answer
A. Dynamic programming B. Back tracking C. Divide and conquer D. Greedy search

52. For the given array, find the arrangement of the elements after 3rd pass of selection sort. Assume that the
array is being sorted in ascending order list ; 33,22, 11, 77, 66, 88, 55
A. 22, 11, 33, 66, 77, 55, 88 B. 11, 22, 33, 55, 66, 77, 88
C. 11, 22, 33, 55, 66, 88, 77 D. 11, 22, 33, 77, 66, 88, 55

53. For solving a problem, which of these in the 1st step in developing a working programme for it? Choose
the correct answer?
A. Writing the program in the programming language B. Writing the step by step algorithm to solve the
problem
C. Compiling the libraries required D. Code debugging

55. Consider the given statement for their correctness with respect to stacks data structure
1. Stacks follow a LIFO approach
2. Stacks are used to convert binary numbers to corresponding decimal numbers.
3. Stacks use two pointers for performing PUSH and POP respectively
A. TTF B. TTT C. TFF D.FTF

56. Which of the following options gives the lower bound on running time for an algorithm?
A. Best case complexity of the algorithm B. Average case complexity of the algorithm
C. Worst case complexity of the algorithm D. Number of iterations taking place in the algorithm

57. function main() {


integeri=0.7
static float m=0.7
if (m equals i)
print ”we are Equal”
else if( m>i )
print ”I am greater”
else
print ”I am lesser”
}
A. We are equal B. I am greater C. I am lesser D.
This code will generate an error

58. Consider an array on which bubble sort is used. The bubble sort would compare the element A[x] to
which of the following elements in a single iteration?
A. A[x+1] B. A[x+2] C.A[x+2x] D. All of these

PAPER-3
59. Choose the correct answer. Consider the statement
while (a < 10.0) {
a = a*a
}
Assuming a is positive, for what value of a will this code statement result in an infinite loop?
A. a < 1.0 B. a <sqrt (10) C. a >sqrt (10) D. a = 0

60. Choose the correct answer. Ankita takes as input 2 integer numbers, a and b, whose value can be
between 0 and 31. He stores them as 5 bit numbers. He writes the following code to process these numbers
to produce a third number c.
c = 2*(a – b)
In how many minimum bits should Ankita store c?
A. 6 bits B. 7 bits C. 8 bits D. 9 bits

61. Recursive function is executed in a ___________________________


A. Last in First Out Order B. First in First Out Order C. Parallel Fashion
D. All of the above

62. Yukta created an interface to use it in different parts of the program by implementing it. But
she forgot to specify the access specifier for each contained method. What will be the access
specifier of the methods that will be inherited/implemented?
A. Public B. Private C. Protected D. An
error will be generated

63. Which of the following statements are true?


1)An Arithmetic left shift multiplies a signed number by two
2)An Arithmetic right shift divides a signed number by two
3)Mask operation is an AND micro-operation and insert is an OR micro-operation
4)In a logical shift, the serial input to the shift is one
A. Both 1 and 2 B. Both 3 and 4 C. 1, 2 and 3 D. 2, 3 and 4

64. Choose the correct answer. A Queue is implemented by a linear array of size 10 (and not as a
circularly connected array). Front and Rear are represented as an index in the array. To add an
element, the rear index is incremented and the element is added. To delete an element, the front
index is incremented. The following operations are done on an empty queue.
ADD 1; DELETE; ADD 2; ADD 3; ADD 4; DELETE, DELETE.
After this set of operations, what is the maximum capacity of the queue?
A. 6 B. 7 C. 10 D. None of these

65. A 8-bit signed integer has the following range?


A. 0 to 255 B. -128 to 127 C. -255 to 254 D. 0 to 509

66. Pankaj makes a program to print the product of cubes of the first 10 whole numbers
She writes the following program:
integer x = 0 // statement 1
integer sum = 0 // statement 2
while ( x < 10 ) // statement 3
{
sum = x*x*x // statement 4
x = x + 1 // statement 5
}
print sum // statement 6
Is her program correct? If not, which statement will you modify to correct it?
A. No error, the program is correct B. Statement 1 C. Statement 4 D. statement 6

67. Here is an infix notation: ((A+B)*C-(D-E))^(F+G) Choose the correct postfix notation of the
above from the given options?
A. AB+CD*E–FG+^ B. AB+C*DE–FG+^ C. AB+C*DE-FG-+^ D. A+BC*DE-FG-+^

68. One of the following options is a form of access used to add and remove nodes from a queue.
A. LIFO B. FIFO C. Both LIFO and FIFO D. None of these

44. What is the time complexity of adding three matrices of size NXN cell-by-cell?
A. O (N) B. O (N^2) C. O (N^3) D. None of these

69. What is the output of the pseudocode statements given below?

(Note: Assume that when two data types are processed through an operator, the answer maintains the same data
type as that of the input. Also, all data types have enough range to accommodate any number. If two different data
types are operated upon, the result assumes the data type that is more expressive.)

integer a=984, b=10


//float is a data type to store real numbers.
float c
c=a/b
print c
A. 984
B. 98.4
C. 98
D. Error

70.What will be the output generated when the given code is executed?A pseudo- code is used which is self
explanatory.

function main()
{
integer a=5
switch(a)
{
default: print “hello”
case 5: print “How are you?”
break

}
A. hello
B. How are you
C. HelloHow are you?
D. This code will generate a compile time error

71. A language has 28 different letters in total. Each word in the language consists of a maximum of 7 letters. A
programmer wants to create a data type to store a word of this language. She decides to store the word as an array
of letters. How many bits should she assign to the data type to store all kinds of words of the language?
A. 7
B. 35
C. 28
D. 196
72. How can the largest number in a list of twenty numbers be found?
A. Use bubble sort to sort the list in a descending order and the print the first number of the series
B. Use selection sort to sort the list in a descending order and the print the first number of the series
C. Implement one iteration of selection sort for descending order and print the first number in the
series
D. None of the above

73. A programmer writes an efficient program to sum two square diagonal matrices (matrices with elements
only on the diagonal positions). The size of each matrix is nXn. What is the time complexity of the algorithm?

A. O(n2)
B. O(n)

C. O(n*log(n))

D. None of the above

74. How many nodes does a full binary tree with “n” leaves contain?
A. 2n + 1 nodes
B. log2n nodes
C. 2n – 1 nodes
D. 2n nodes

75. The following values are to be stored in a hash Table-15,22,41,19,102,18,37


Using the division method of hashing with a table size of 10 (use sequential method of resolving collision),give the
contents of Hash Table.
A. 41,22,102,15,37,18,19,Null, Null, Null
B. Null, Null, Null,41,22,102,15,37,18,19
C. 41,22,102,15,37,18,19
D. Null,41,22,102,Null, 15,Null, 37,18,19

76. Consider the code given below. How many times will “Hello” be printed if m<n and exactly one of (m,n) is
even?

fori= m to n increment 2

{ print “Hello!” }

A. (n – m + 1)/2

B. 1 + (n –m)/2

C. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd

D. (n – m + 1 )/2 if m is even,1 + (n – m )/2 if m is odd

Choose the correct answer.


77. The function given below takes a number “n” as the input and calculates the sum of first “n” natural
numbers. Which of the following statements should be inserted in place of “??” to get the required output?
function sum(n)
{
if (??)
return 1
else
return (n + sum(n-1))
end
}
A. n equals 1
B. n equals 2
C. n>= 1
D. n>1
Choose the correct answer.
78. Which of the following implies that there are two loops that are nested?
A. Two loops, one after the other
B. Two loops, one inside the other
C. One loop with two different iteration counts
D. Two loop with the same iteration count
79.Choose the correct answer.
Passage
function main()
{
static integer abc = 5
print abc—
if ( abc )
main() // calling main function
}
Choose the correct answer:
A pseudo-code is used which is self explanatory.
// in pseudo code refers to comment
What will be the output of the given code?
A. 43210
B. 54321
C. This code will enter an infinite loop
D. This code will generate an error
Choose the correct answer.
80. The function given below takes an even integer “n” as the input and calculates the sum of first “n” even
natural numbers. The function is called by the statement “sum (30)”. How many times will the function
“sum” be called to compute the sum?
function sum(n)
{
if (n equals 2)
return 2
else
return (n + sum(n-2)
end
}
A. 1
B. 30
C. 15
D. 16
Passage
Class rocket
{
private:
integer height, weight
public: \\statement 1
function input a, int b)
{
height = a;
weight = b;
}
}
function main( )
{
Rocket rocket1, rocket2
}
Choose the correct answer.
81. Refer to the pseudocode given in the ‘Passage’. The code is similar to that in C++ and is self-
explanatory. An accessible member Funcction and a data member for an object are accessed by the
statements objectname. Functionname and objectname. Datamemnername, respectively.
What can be inferred from this code?
A. “rocket” is a class with “rocket1” and “rocket2” as its objects, with “height” and
“weight” as its attributes.
B. “rocket” is a class with “rocket1” and “rocket2” as its objects, with “height” and
“weight” as its objects.
C. “rocket” is a class with “rocket1” and “rocket2”, “height” and “weight” as its attributes.
D. “rocket” is a class with “rocket1” and “rocket2”, “height” and “weight” as its objects.
Choose the correct answer.
82. In which of the following situations can a constructor be invoked?
A. When an object is created
B. When an object is assigned the value 0
C. Only at the end of the code
D. When the scope of the object is over

Choose the correct answer.


83. What will happen if some indentations are made in some statements of a code written in C++?
A. Faster execution of the code
B. Lower memory requirement for the code
C. Correction of errors in the code
D. Better readability of the code.
Choose the correct answer.
84. In an implementation of a linked list, each node contains data and address. Which of the following can
the address field possibly contain?
A. Address of the next node in sequence
B. Its own address
C. Address of the last node
D. Address of the first node
Choose the correct answer.
85. Consider the structure of a queue as given below –
FRONT = 2, REAR = 4
Queue: _, L, M, N, _
What will be the values of FRONT and REAR respectively after the insertion of an element ‘Q’
in the given queue?
A. 1,4
B. 2,5
C. 1,5
D. 2,4

Choose the correct answer.


86. Which of the following can be inherited by a derived class from a base class?
A. Data members
A. Member functions
B. Constructors and destructors
C. Data members and member functions
Choose the correct answer.
87. A programmer wants the program given below to print the largest number out of three numbers
entered by the user.
int number1, number 2, number 3, temp;
input number 1, number 2, number 3;
if (number1>number2)
temp = number 1
else
temp = number 2
end if
if (??) // Statement 1
temp = number 3
end if
print temp
Which of the following should be substituted in place of “??” in Statement 1 in the code?
A. number3> number2
B. number3> temp
C. number3<temp
D. number3> number1
88. A queue is implemented as a singly-linked-list for easy addition and deletion of elements. Each node has
an element and a pointer to another node. Which node will point to empty/no location?
a) Rear
b) Front
c) Both
d) None
Passage
function moify(y,z)
{
y = y + 1;
z = z + 1;
return y – z
}
function calculate ( )
{
integer a = 5, b = 10, c
c = modify (a, b);
print a
print space
print c
{
89. Consider the code given in the ‘Passage’. Assume that “a” and “b” are passed by value. What
will the output of the program be when the function clculate () is executed?
A. 11 -5
B. 10 -5
C. 6 -5
D. 5 -5
Passage
function preordertraverse(node)
{
print node value
if (condition x)
{ preoedertraverse(node left)}
if condition y)
{ preordertraverse(node right)}
return
}
Choose the correct answer.
90. Consider a binary tree implementation. The root address is stored in the vatiable root. The
address of a node is given in the variable node. The value of the node and its right and left child
nodes can be accessed usina the statements given below.
node value,
node right,
node left.
A programmer writes the function given in the ‘Passage’ to do a preorder traversal of the tree.
What are Condition X and Condition Y ?
A. Condition X: node left isnotequal
Condition Y: node right isnotequal
B. Condition X: node right isnotequal
Condition Y: node left isnotequal
C. Condition X: node left isequal
Condition Y: node right isequal
D. Condition X: node right isequal
Condition Y: node left isequal
Choose the correct answer.
91. The following operations are performed on an empity R “A”.
PUSH( 1)
PUSH (2)
POP
PUSH(5)
PUSH(6)
POP
What will the stack contain after these operations?
(Note: The top of the stack is underlined in the options below.)
A. 5 6
B. 1 5
C. 5 6
D. 1 5
92.Choose the correct answer.
Passage
Function main()
{
Automatic variable var
Print var
}
Choose the correct answer.
A pseudo-code is used which is self explanatory.
What will be the output generated when the given code is executed?
A. 0
B. 1
C. Garbage Value
D. This code will generate a compile time error
Choose the correct answer.

93. The program to print the sum of all cubes that lie between 0 and 100 is given below. Does this
program have an error? If yes, which statement should be modified to correct the program?
integer i = 0,a // Statement 1
integer sum = 0;
a = (i * i * i)
while (1<100) // Statement 2
{
sum = sum + a // Statement 3
i=i+1
a = (i * i * i ) // Statement 4
}
Printsum
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. No error
Choose the correct answer.
Passage
function MyFunc 1(integer n)
{
return n*2
}
function MyFunc2(integer n)
{
print “The value is “ n
}
Choose the correct answer.
A pseudo-code is used is used which is self explanatory.
94. Which of the given two functions can be categorized as procedure?
A. My Func 1
B. My Func 2
C. Both MyFunc1 and MyFun2
D. A function cannot be a procedure
Choose the correct answer.
95. Which of the following statements is TRUE about a breadth first search?
A. Beginning from a node, all the adjacent nodes are traversed first
B. Beginning from a node, each adjacent node is fully explored before traversing the next
adjacent node
C. Beginning from a node, the nodes are traversed in cyclic order
D. None of the above
Choose the correct answer.
96. How does inheritance relate to abstraction?
A. A base class is an abstraction of all its derived classes.
B. A derived class is an abstraction of all its base classes.
C. Base and derived classes are abstractions of each other.
D. Inheritance prevents abstraction.
Choose the correct answer.
97. A data type is stored as a 6-bit signed integer. Which of the following cannot be represented
by this data type?
A. -12
B. 0
C. 32
D. 18
Fill in the blank
98. Each bucket in a Hash Table is the head of ______________.
A. A Heap
B. A Stack
C. An Array
D. A Queue
99.Choose the correct answer.
passage
class entity
{
private:
integer a,b
public:
integer c
function entity () {a= 0; b=0}
function compare ( )
{if (a>b) return 1;
return 0
}
}
function main( )
{
entityn black
int value 2 = 5
value = black. compare() // Statement 1
black.c = value02 // Statement2
print black a // Statement 3
Refer to the pseudocode given in the ‘Passage’. The code is similar to that in C++ and is self-
explanatory. An accessible member function and a data member for an object are accessed by the
statements objectname. functionname and objectname. datamemnername, respectively. Identify
the statement with an error.
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. None of the above
Choose the correct answer.
100. What is the maximum number of edges in an undirected graph with “n” vertices?
A. n*(n-1)/2
B. n*(n+1)/2
C. n*n
D. 2*n
Choose the correct answer.
101.What will be returned if f(a,b) is called in the following functions?
function g(int n)
{
if (n>0) return 1;
else return -1;
}
function f(int a, int b)
{
if (a>b) return g(a-b);
if (a<b) return g(-b+a);
return 0;
}
A. Always +1
B. 1 if a>b, -1 if a<b, 0 otherwise
C. -1 if a>b, -1 if a<b, 0 otherwise
D. 0 if a equals b, -1 otherwise
Choose the correct answer.
102. In the execution process of a program, this technoque involves the intermediate
representation to be compiled to native machine code at runtime. What is the name of this
technique?
A. Static compilation
B. Run time interpretation
C. Static interpretation
D. Just in time compilation
103.Tricha needs to store a list of binary data. Which of the following data types should she use?
A. Integer
B. Float
C. Character
D. Boolean
Choose the correct answer.
104. A programmer writes an efficient program to add two upper triangular 10X10 matrices with
the elements on the diagonals retained. How many total additions will the program make?
A. 100
B. 55
C. 25
D. 10
Choose the correct answer.
105. A problem to be solved is broken into a sequence of smaller sub-problems until a stage where
the sub-problem can be easlved. What is this design approach called?
A. Top-Down approach
B. Bottom-Up approach
C. Procedural programming
D. None of the above
Choose the correct answer.
106. What is the difference between a function and a method?
A. Function is a named code unlike method which is a part of an object
B. Function contained in an object is called a method
C. Function cannot change variables outside its scope unlike method
D. There is no difference between the two
Choose the correct answer.
107. Which of the following is the lowest level format to which the computer converts a program
in ahigher language before execution?
A. English code
B. Machine code
C. Assembly language
D. System language
108.
Passage
class brush
{
private:
integer size, c
rcode
function getdata( ) { …. }// Statement 1
public:
integer name // Statement 2
function putdata( ) { …. }
}
function main
{
brush b1, b2
print b1.name //Statement 3
b2.getdata( ) //Statement 4
}
Choose the correct answer.
109. Refer to the pseudocode given in the ‘Passage’. The code is similar to that in C++ and is self-
explanatory. An accessible member Funcction and a data member for an object are accessed by
the statements objectname. Functionname and objectname. Datamemnername, respectively.
Which statement should be deleted from the code to rectify the error in it?
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
Choose the correct answer.
110. A developer writes the program given below to print the sum of the squares of the first five
whole numbers(0…4). Is the program correct? If not, which statement should be modified to
correct the program?
integer i = 0 // Statement 1
integer sum = 0 // Statement 2
while (i<5) // Statement 3
{
sum = i*i // Statement 4
i = i + 1 // Statement 5
}
print sum // statement 6
A. No error, the program is correct
B. Statement 1
C. Statement 4
D. Statement 6
Choose the correct answer.
111. The program to print the sum of all cubes that lie between 0 and 100 is given below. Does
this program have an error? If yes, which statement should be modified to correct the program?
integer i = 0, a // Statement 1
integer sum = 0;
a = (i * i *i)
while (i<100) // Statement 2
{
sum = sum + a // Statement 3
i=i+1
a = (i * i * i) // Statement 4
}
print sum
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. No error
112.Passage
integer i = 1 // Statement 1
while (i<= 3 )
{
int j // Statement 2
while ( j<= i ) // Statement 3
{
print j
print blank space
j = j + 1 // Statement 4
}
print end-of-line //takes the cursor to the next line
i=i+1
}
Choose the correct answer.
113. A programmer writes the program given in the ‘Passage’ to print the following pattern on the
screen:
1
12
123
Will this program function properly? If not, which statement should be modified?
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. This program will function properly
114.Choose the correct answer.
An Array MyArr with 10 rows and 15 columns is stored in a row major fashion in the memory.
Given that the starting address of MyArr is 1000 and each element’s size is 1, find the address of
MyArr[6][11]. (Assume the lower bounds on columns and rows of this Array as 1 and 1
respectively)
A. 1105
B. 1060
C. 1160
D. 1085
Choose the correct answer.
115. What is implied by the argument of a function?
A. The variables passed to the function when it is called
B. The value that the function returns on execution
C. The execution code inside function
D. Return type of the function
Choose the correct answer.
116. Preeti writes a program in low level language, now she wants to translate it into a higher
language without rewriting the program. What another program she must use for this purpose?
A. Compiler
B. Decompiler
C. Interpreter
D. Executer
E. Cross compiler
Choose the correct answer.
117.A programmer prepares a questionnaire with “true or false” type of questions.He wants to
define a data type that stores the responses of the candidates for the questions. Which of the
following is the most suited data type for this purpose?
A. Integer
B. Boolean
C. Float
D. Character
Choose the correct answer.
118.Which of the following data structures may produce an overflow error even though the
current number of elements in it lower than its size?
A. A queue implemented in a linear array
B. A queue implemented in a circularly connected array
C. A stack implemented in a linear array
D. None of the above
Choose the correct answer.
119. X and Y are asked to write a program to sum the rows of a 2X2 matrix stored in an array A.
X writes the code (Code A) as follows:
For n = 0 to 1
sumRow1 [n] = A[n][1] + A[n][2]
end
Y writes the code (Code b) as follows:
Sum Row1[0] =A[0][1] + A[0][2]
Sum Row1[1] = A[1][1] + A[1][2]
Which of the following statements is correct about these codes if no loop unrolling is done by the
compiler?
A. Code A would execute faster than Code B.
B. Code B would execute faster than Code A.
C. Code A is logically incorrect.
D. Code B is logically incorrect.
Choose the correct answer.
120.A programmer tries to debug a code of 10,000 lines. It is known that there is a logical error in
the first 25 lines of the code. Which of the following is an efficient way to debug the code?
A. Compile the entire code and check it line by line.
B. Use an interpreter on the first 25lines of code.
C. Compile the entire code and run it.
D. None of the above can be used to debug the code.
Choose the correct answer.
121. For the given list of numbers, how many awaps will take place in Bubble Sort so that the list
becomes sorted?
(Assume that the list is being sorted in ascending order)
List 23, 56, 78, 3, 11, 65
A. 4
B. 5
C. 6
D. 7
Choose the correct answer.
122. Which of the following gives the maximum number of nodes at level :I’ of a binary tree?
(Note: The root is at level 1.)
A. 2I-1
B. 3I-1
C. 2I
D. 2I -1
Passage
Integer num 1, num2
Input num1, num2
Integer k=0, final=num1
//missing statements
Print final
Choose the correct answer:
A pseudo-code is used which is self explanatory.
//in pseudo code refers to comment
123.Reema wanted to multiply two numbers but the * key of her keyboard is broken. She decides
to write the program without using * operator. She writes the given code, where some statements
are missing.
What should be the missing statements in the given code?
A. While(k++ < num1)
final+=num1
B. While(k++ < num2-1)
final+=num1
C. While(k++ < num2)
final+=num1
D. While(k++ < num2)
final+=num2
Choose the correct answer.
124. A developer writes the program given below to print the sum of the squares of the first five
whole numbers(0…4). Is the program correct? If not, which statement should be modified to
correct the program?
integer i = 0 // Statement 1
integer sum = 0 // Statement 2
while (i<5) // Statement 3
{
sum = i*i // Statement 4
i = i + 1 // Statement 5
}
print sum // statement 6
A. No error, the program is correct
B. Statement 1
C. Statement 4
D. Statement 6
Choose the correct answer.
Choose the correct answer.
125.Which tree (s) from the given figure is/are Heap(s)?
A. Only 1
B. Only 2
C. Only 3
D. Both 1 and 2
E. Both 1 and 3
Passage
class entity
{
private:
integer a,b
public:
integer c
function entity () {a= 0; b=0}
function compare ( )
{if (a>b) return 1;
return 0
}
}
function main( )
{
entityn black
int value 2 = 5
value = black. compare() // Statement 1
black.c = value02 // Statement2
print black a // Statement 3
126. Refer to the pseudocode given in the ‘Passage’. The code is similar to that in C++ and is self-
explanatory. An accessible member function and a data member for an object are accessed by the
statements objectname. functionname and objectname. datamemnername, respectively. Identify
the statement with an error.
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. None of the above
Choose the correct answer.
127. Which of the following options is not an instance of exponential complexities?
A. O(nn)
B. O(2n)
C. O(n!)
D. O(n3)
Choose the correct answer.
128. A sorting algorithm traverses through a list, comparing adjacent elements and switching them
under certain conditions. What is this sorting algorithm called?
A. Insertion sort
B. Heap sort
C. Quick sort
D. Bubble sort
Choose the correct answer.
129. What will be the input to the second pass, if the list before starting the Radix Sort is: 729,
150, 123, 931, 348, 517?
A. 150, 123, 348, 517, 729, 931
B. 150, 931, 123, 517, 348, 729
C. 517, 729, 123, 931, 348, 150
D. 123, 150, 348, 517, 729, 931
Choose the correct answer.
Passage
class brush
{
private:
integer size, c
rcode
function getdata( ) { …. }// Statement 1
public:
integer name // Statement 2
function putdata( ) { …. }
}
function main
{
brush b1, b2
print b1.name //Statement 3
b2.getdata( ) //Statement 4
}
Choose the correct answer.
130. Refer to the pseudocode given in the ‘Passage’. The code is similar to that in C++ and is self-
explanatory. An accessible member Function and a data member for an object are accessed by the
statements objectname. Functionname and objectname. datamembername, respectively. Which
statement should be deleted from the code to rectify the error in it?
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
Choose the correct answer.
Passage
Integer MyVar1=5
Function main().
{
Integer MyVar1=9
Print MyVar1
Print//missing code
}
Choose the correct answer:
A pseudo-code is used which is self explanatory.
// in pseudo code refers to comment
131. Assuming that main() is the starting point of execution of program, which of the following
options should replace the //missing code so as to print the value of global MyVar1 (value = 5)?
A. MyVar1.MyVar1
B. MyVar1[0]
C. ::MyVar1
D. No local variable should have the same name as the global variable
Choose the correct answer.
132. Assume the following precedence (high to low). Operators in the same row have the same
precedence.
( )
*/
+ -
AND
OR
The precedence is from left left to right in the expression for the operators with equal precedence.
Which of the following statements is TRUE about the output of the code statements given below?
integer a = 40, b = 35, c = 20, d = 10
print a *b / c – d
print a * b / (c – d)
A. The outputs differ by 80.
B. The outputs the same.
C. The outputs differ by 50.
D. The outputs differ by 160.
Choose the correct answer.
133. A developer writes the program given below to print the sum of the squares of the first five
whole numbers(0…4). Is the program correct? If not, which statement should be modified to
correct the program?
integer i = 0 // Statement 1
integer sum = 0 // Statement 2
while (i<5) // Statement 3
{
sum = i*i // Statement 4
i = i + 1 // Statement 5
}
print sum // statement 6
A. No error, the program is correct
B. Statement 1
C. Statement 4
D. Statement 6
Choose the correct answer.
134.Which of the following best describes the space complexity of a program?
A. Amount of hard disk space required to store the program
B. Amount of hard disk space required to compile the program
C. Amount of memory required for the program to run
D. Amount of memory required for the program to compile

Choose the correct answer.


135. Which of the following members of a class cannot be inherited?
A. Public
B. Private
C. Private and Protected
D. Protected
Choose the correct answer.
Fill in the blanks
136. _________ returns a value unlike _____________.
A. Procedure, Subroutine
B. Procedure, Function
C. Function, Method
D. Function, Procedure
Choose the correct answer.
137. In har graph, Yelena has included 10 nodes. Which of the following options will help her know
if there exists a path between node 4 and node 9?
A. Best First Search
B. Topological Sort
C. Eulerian Tour
D. Floyd-Warshall’s algorthm
Choose the correct answer.
Passage
function main ()
{
integer a=5, b=7
switch(a)
{
case 5:print”i am 5”
break
case b:print”i am not 5”
break
default: print “i am different”
}
}
138.Choose the correct answer:
A pseudo-code is used which is self explanatory.
Q) What will be the output generated when the given code is executed?
A. I am 5
B. I am not 5
C. Iam different
D. This code will generate an error
Passage.

Choose the correct answer:


139. What will be the Postorder traversal of the given Binary tree?
A. DCIHFBGEA
B. DEBIFHAEG
C. DCIFBGEA
D. ABCDFIHGE
Choose the correct answer:
140. Which of the following items may or may not have its methods' implementations?
A. Interface
B. Abstract Class
C. Generic Class
D. Anonymous Class
Choose the correct answer
141. The function given below computes the factorial of the number “n” entered by a user. What
should be the “MISSING STATEMEN” in order to make the code work properly?
Function factorial(n)
{
If (n equals 1)
Return 1
Else
--MISSING STATEMENT –
End
}
A. return factorial(n-1)
B. return n*factorial(n)
C. return n*(n-1)
D. return n*factorial(n-1)
Choose the correct answer.
142. Two programmers X and Y are asked to write a code to evaluate the following expression:
a – b + c/(a-b) + (a-b)2
x writes the following code statements (code a):
print (a-b) + c/(a-b) + (a-b)*(a-b)
y wites the following code statements (code b):
b = (a-b)
print d + c/d + d*d
Which of the following is TRUE if the time taken to load a value in a variable for addition,
multiplication or division between two operands is the same?
A. Code A uses lesser memory and is slower than Code B.
B. Code A uses lesser memory and is faster than Code B.
C. Code A uses more memory and is faster than Code B.
D. Code A uses more memory and is slower than Code B.
Fill in the blank
143. Merge Sort requires O(n) space when implemented using ____________ .
A. Array
B. Linked List
C. Both Array and Linked List
D. Merge Sort can be implemented using constant space irrespective of the implementing data
structure
Choose the correct answer
144. A function in the base class is redefined in the inherited class. What is the term used to describe this
situation?
A. Inheritance
B. Overriding
C. Overloading
D. Encapsulation
. 145.What is the minimum number of stacks of size “n” required to implement a queue of size “n”?
A. 1
B. 2
C. 3
D. 4

146. ___________ is the compile time binding whereas _________________ is run time binding of functions.

A. Function overriding. Function overloading


B. Abstraction, Encapsulation
C. Function overloading, Function overriding
D. Varies from program to program

147. A programmer writes a code snippet in which a set of three lines occurs ten times in different parts of the
program. What programming concept should be used to shorten the code length?
A. For loops
B. Functions
C. Arrays
D. Classes
148. Which of the following will create an object named pigeon of the class Bird in C++?
A. pigeon bird
B. bird pigeon
C. Object pigeon of bird
D. None of the above

149. enum names {AMAR,AKBAR, ANTHONY}


function main()
{
print AMAR
print AKBAR
print ANTHONY
}
A pseudo-code is used which is self explanatory.
What will be the output generated when the given code is executed?
A. 000
B. 012
C. 123
D. 111

150. What is a function contained within a class called in c++?


A. A member function
B. An operator
C. A class function
D. A method

151. A programmer writes a sorting algorithm that takes different of time to sort two different lists of equal size.
What is the possible difference between the two lists?
A. All numbers in one list are more than 100 while in the other are less than 100
B. The ordering of numbers with respect to the magnitude in the two lists has different properties.
C. One list has all negative numbers while the other has all positive numbers.
D. One list contains 0 as an element while the other does not.

152. When a byte code is interpreted, how does it get affected in contrast with the compiled machine code?

A. It has the same running time as of the machine code


B. It runs faster than the compiled machine code
C. It runs slower than the compiled machine code
D. Interpretation does not make any difference in the byte code running time
153.Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the
program. What programming concept can he use to shorten his program code length ?
A. Use for loops
B. Use functions
C. Use arrays
D. Use classes

154.Aparajita wants to make a function that is not bound to any identifier. Which of the following
functions should she incorporate in her program?

A. Anonymous Function
B. Friend function null Function
C. Null Function
D. Global Function

155.These are loops which are nested. This implies which one of the following?

A. Two loops, one after the other


B. Two loops, one inside the other
C. One loop with two different iteration counts
D. Two loops with the same iteration count

156.Piyush wrote a Binary Search program which asked the user for two inputs the list of numbers
and the item to be searched for the list entered is ( 5, 7, 11, 12, 19, 20, 25 ) and Number to be
searched : 19How many comparisons will be brought out by the program for searching this item
using Binary Search ?

A. 2
B. 3
C. 5
D. 7

157.What is the term used to describe the situation, when a function in the base class is redefined in
the inherited class ?
A. Inheritance
B. Overriding
C. Overloading
D. Encapsulation

158.In an implementation of a linked list, each node contains data and address. Which of the
following could the address field possibly contain?

A. Address of next node in sequence


B. Its own address
C. Address of last node
D. Address of first node

159.A queue is implemented as a (singly linked) linked-list. Each node has an element and pointer
to another node. Rear and front contain the addresses of the rear and front node respectively. If the
condition (rear isequal front) is true and neither is NULL, what do we infer about the linked list ?

A. It has no elements
B. It has one elements
C. There is an error
D. None of these

160.A function contained within a class is called......?

A. A member function
B. An operator
C. A class function
D. A method

161.In Object Oriented Programming, there should never be more than one reason for a class to
change. There should be only one reason for the existence of the class. Which of the following
principles states the same?

A. Unique responsibility reason


B. Single reason principle
C. Single responsibility principle
D. Unique reason principle

162.In C++, which of the following creates a pigeon object of class bird?

A. Pigeon bird
B. Bird pigeon
C. Object pigeon of bird
D. None of these
163.A full binary free with n non-leaf nodes contains

A. (log n) nodes
B. n + 1 nodes
C. 2n + 1 nodes
D. 2n nodes

164.The maximum number of nodes on level I of a binary tree is which of the following ? (Root is
level 1)

A. 2I-1
B. 3I-1
C. 2I
D. 2I-1

165.What are the maximum number of edges in a n vertex undirected graph?

A. n*(n-1)/2
B. n*(n+1)/2
C. n*n
D. 2*n

166.Zenab and Shashi independently write a program to find the mass of one mole of water, which
includes mass of hydrogen and oxygen. Zenab defines the variables: Integer hydrogen, oxygen,
water // Code A. While Shashi defines the three quantities as: Integer a, b, c // Code B. Which is a
better programming practice and why?

A. Code B is better because variable names are shorter


B. Code a is better because the variable names are understandable and non-confusing
C. Code A will run correctly, while Code B will give an error.
D. Code B will run correctly, while Code A will give an error.

167.As part of the maintenance work, you are entrusted with the work of rearranging the library
books in a shelf in proper order, at the end of each day. The ideal choice will be Bubble sort

A. Insertion Sort
B. Selection Sort
C. Heap Sort
D. None

168.Which of the following data types does not belong to the category of abstract data types?

A. Hashtable
B. Set
C. Object
D. Stack

169.How many instances of an abstract class can be created?

A. 1

B. 5

C. 13

D. 0

170.Which of the following is an abstract data type?

A. int

B. double

C. string

D. Class

171.Which of the following concepts of OOPS means exposing only necessary information to client?

A. Abstraction

B. Encapsulation

C. Data hiding

D. Data binding

172.Which of the following cannot be inherited?

A. Friend

B. Static

C. Destructor

D. None of the above

173.Which type of inheritance needs a virtual function?

A. Multi-level inheritance

B. Multiple inheritance

C. Hybrid inheritance
D. All the above

174.Virtual function that has no definition within the base class is called?

A. Pure virtual function

B. Pure static function

C. Pure Const function

D. Virtual Function

175.Syntax for Pure Virtual Function is?

A. virtual void show()==0

B. void virtual show()==0

C. virtual void show()=0

D. void virtual show()=0

176.How will a class protect the code inside it?

A. Using Access specifies

B. Abstraction

C. Use of Inheritance

D. All of the mentioned

177.Shankar works all night long writing code and writing more and more classes for each object he now
thinks that he can write a superclass which defines some hierarchical feature for other classes, what can he
use?

A. Cascading

B. Hierarchical Super Positioning

C. Inheritance

D. Polymorphism

178.Pooja wants to write code for his computer class homework but he had misheard the teacher and only
can recollect remembering this 4 words. Which of the following is what he couldn’t have had heard?

A. Distributive

B. Multilevel
C. Multiple

D. Hierarchical

179.In case of the worst timing, which might be the worst to implement in sorting algorithm?

A. Quick

B. Merge

C. Tim

D. Heap

180.There are 2 buildings and on each’s window, a flower pot is kept. Ravi’s mother tells him to add each
cell/window to the other and store in a matrix? What would be time complexity if he writes a code to do
so?

A. Theta(n)

B. Theta( log n)

C. Theta(n^2)

D. Theta(n log n)

181.Which of the following has the quickest average time complexity?

A. Quick

B. Radix

C. Bubble

D. Heap

182.In regards to time complexity which will perform better ?(n^4) or O(n^3)?

A. (n^4)

B. O(n^3)

C. Both Equally

D. Cannot be said

183.Which of the following case does not exist in complexity theory?


A. Best case

B. Worst case

C. Average case

D. Null case

184.The complexity of linear search algorithm is

A. O(n)

B. O(log n)

C. O(n2)

D. O(n log n)

185.The Worst case occur in linear search algorithm when

A. Item is somewhere in the middle of the array

B. Item is not in the array at all

C. Item is the last element in the array

D. Item is the last element in the array or is not there at all

186.What is space complexity of the program?

A. Amount of hard disk space required to store the program.

B. Amount of hard disk space required to compile the program.

C. Amount of memory required by the program to run.

D. Amount of memory required by the program to compile.

187.A code with ?(n) and ?(n^2). Which code will execute faster for a code of size J?

A. ?(n)

B. ?(n2)

C. Cannot be said as size of K is unknown

D. Both will be equal

188.Which memory device is generally made of semi-conductors?


A. RAM

B. Hard-disk

C. Floppy disk

D. CD disk

189.Register renaming is done in pipelined processors

A. as an alternative to register allocation at compile time

B. for efficient access to function parameters and local variables

C. to handle certain kinds of hazards

D. as part of address translation

190.The amount of ROM needed to implement a 4 bit multiplier is

A. 64 bits

B. 128 bits

C. 1 Kbits

D. 2 Kbits

191.Group A -A. Hit ratio B. Pages C. Frames D. External fragmentation Group B -1. Logical memory 2.
Compaction 3. Translation look-aside buffer 4. Physical memory

A. A-2, B-4, C-1,D-3

B. A-3, B-1,C-4, D-2

C. A-2;B-1.;C-4; D-3

D. A-1; B-3; C-4; D-2

192.A RAM chip has a capacity of 1024 words of 8 bits each (1K × 8). The number of 2 × 4 decoders with
enable line needed to construct a 16K × 16 RAM from 1K × 8 RAM is

A. 4

B. 5

C. 6

D. 7
193.The format is usually used to store data.

A. BCD

B. Decimal

C. Hexadecimal

D. Octal

194. I have a problem to solve which takes as input a number n. The problem has a property that given the
solution for (n-1), I can easily solve the problem for n. Which programming technique will I use to solve
such a problem?
a) Iteration
b) Decision-making
c) Object Oriented Programming
d) Recursion

195.The memory space needed by an algorithm has a fixed part independent of the problem instance solved
and a variable part which changes according to the problem instance solved. In general, which of these two is
of prime concern to an algorithm designer?
a) Fixed part
b) Variable Part
c) Product of fixed part and variable part
d) None of these

196.Riyaz has a book of tickets and wants to store ticket numbers in a data structure. New tickets are added
to the end of the booklet. Ticket at the top of the stack is issued to the customer. Which data structure should
Riyaz use to represent the ticket booklet?
a) Queue
b) Stack
c) Array
d) Graph

197.A[0…19] is an array of maximum size 20. The number of elements it contains is stored in the variable,
numberElements. Currently it contains 11 elements. Swati wants to insert an element val after the mth
element in the array. She writes the following code for it:
for X
A[n+1] = A[n]
end
A[m] = val
Fill in X.
a) n = (m+1) to (numberElements-1) increment 1
b) n = m to numberElements increment 1
c) n = m to (numberElements-1) increment 1
d) n = (m+1) to (numberElements) increment 1
198.For a binary search tree, which traversal will result in a sorted list?
a) Preorder
b) Inorder
c) Postorder
d) None of these

199.Fiza have a binary search tree and want to derive a list sorted in descending order from it. For each node,
what traversal ordering will Fiza use?
a) left sub-tree, root, right sub-tree
b) root, left sub-tree, right sub-tree
c) right sub-tree, root, left sub-tree
d) root, right sub-tree, left-subtree

200.Rashmi works on a computer where the time of comparing two numbers is very high and this time
dominates the execution time. She implements a few different sorting algorithms. One algorithm out of these
always took the same amount of execution time irrespective of the input array. Which sorting algorithm was
this?
a) Quicksort
b) Bubble sort
c) Insertion Sort
d) None of these

201.A queue is implemented by a linear array of size 10 (and not as a circularly connected array). Front and
Rear are represented as an index in the array. To add an element, the rear index is incremented and the
element is added. To delete an element, the front index is incremented. The following operations are done on
an empty queue.
ADD 1; DELETE; ADD 2; ADD 3; ADD 4; DELETE, DELETE
After this set of operations, what is the maximum capacity of the queue?
a) 6
b) 7
c) 10
d) None of these

202.Ragu writes a program to find an element in the array A[5] with the following elements in order: 18 32
44 46 57. She runs the program to find a number X. X is found in the first iteration of binary search. What is
the value of X?
a) 44
b) 18
c) 46
d) 32

203.An array contains the following elements in order: 7 6 12 30 18. Insertion sort is used to sort the array in
ascending order. How many times will an insertion be made?
a) 2
b) 3
c) 4
d) 5

204.A hash table can store a maximum of 10 records. Currently there are records in locations 1, 3, 4, 7, 8, 9,
10. The probability of a new record going into location 2, with a hash function resolving collisions by linear
probing is
a) 0.6
b) 0.1
c) 0.2
d) 0.5

205.Farhan writes a code to find the factorial of an inputted number. His code gives correct answers for some
inputs and incorrect answers for others. What kind of error does his program have?
a) Syntactical error
b) Run-time Error
c) Logical Error
d) None of these

206.Number of possible ordered trees with 3 nodes A, B, C is


a) 16
b) 12
c) 13
d) 14

207.Geeta takes as input 2 integer numbers, a and b, whose value can be between 0 and 31. She stores them
as 5 bit numbers. She writes the following code to process these numbers to produce a third number c à c =
2*(a – b) In how many minimum bits should Geeta store c?
a) 6 bits
b) 7 bits
c) 8 bits
d) 9 bits

208.In a sequential programming language, code statements are executed in which order?
a) All are executed simultaneously
b) From top to bottom
c) From bottom to top
d) None of these

209.What is the third number from the left while doing bubble sort in the 3rd iteration for 5 1 4 2 8?
A. 4
B. 5
C. 2
D. 8

210.In c++ how are protected members of a base class accessed in derived class when inherited privately
A. Privately
B. Publicly
C. Protectedly
D. Not Inherited

211.Which of the following statements is correct when a class is inherited publicly?


A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class.

212..Which of the following access specifies is used in a class definition by default?


A. Protected
B. Public
C. Private
D. Friend

213.Which of the following can access private data members or member functions of a class?
A. Any function in the program.
B. All global functions in the program.
C. Any member function of that class.
D. Only public member functions of that class.

214.Which of the following statements about virtual base classes is correct?


A. It is used to provide multiple inheritance.
B. It is used to avoid multiple copies of base class in derived class.
C. It is used to allow multiple copies of base class in a derived class.
D. It allows private members of the base class to be inherited in the derived class.

215.State whether the following statements about inheritance are True or False. i) A public member
of a class can be accessed by its own objects using the dot operator. ii) While inheriting, the private
members of the base class will never become the members of its derived class.
A. True, False
B. False, True
C. True, True
D. False, False

216.Encapsulation is?
A. Binds together code and data
B. Using single interface for general class of actions.
C. Reduce Complexity
D. All above

217.Which of the following concepts means wrapping up of data and functions together?
A. Abstraction
B. Encapsulation
C. Inheritance
D. None

218.Tarun wants to write code for his computer class homework but he had misheard the teacher
and only can recollect remembering this 4 words. Which of the following is what he couldn’t have
had heard?
A. Distributive
B. Multilevel
C. Multiple
D. Hierarchical

219.Tarun works all night long writing code and writing more and more classes for each object he
now thinks that he can write a superclass which defines some hierarchical feature for other classes,
what can he use?
A. Cascading
B. Hierachical Super Positioning
C. Inheritance
D. Polymorphism
220.Palak enters a coding competition she wants to write code to pass down values from one class to
another?
A. Inherits
B. extends
C. Construct
D. all of the mentioned

221.Which of the following operator is overloaded for object cout?


A. +
B. >>
C. <<
D. =
E. ()

222.Which of the following operators cannot be overloaded? A B C


A. *
B. ->
C. []
D. ?:
223.A code takes the following code steps (equivalently time unit) to execute:5*n3 + 6*n2 + 1. Which of the
following is not true about the time complexity of theprogram?

Op 1: It has a time complexity of O(n3)


Op 2: It has a time complexity of O(n4)
Op 3: It has a time complexity of O(n2)
Op 4: It has a time complexity of &theta(n3)
224.Gautam is given two codes, A and B, to solve a problem, which have complexity &theta(n) and
&theta(n2) respectively. His client wants to solve a problem of size k, which Gautam does not know. Which
code will Gautam deliver to the client, so that the execution is faster?
Op 1: Code A
Op 2: Code B
Op 3: Gautam cannot determine
Op 4: Both codes have the same execution time, so deliver any.

225.Surbhi is given two codes, A and B, to solve a problem, which have complexity O(n3) and &omega(n4)
respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will
Surbhi deliver to the client, so that the execution is faster?
Op 1: Code A
Op 2: Code B
Op 3: Surbhi cannot determine
Op 4: Both codes have the same execution time, so deliver any.

226.Vibhu is given two codes, A and B, to solve a problem, which have complexity O(n4) and &omega(n3)
respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code will
Gautam deliver to the client, so that the execution is faster?
Op 1: Code A
Op 2: Code B
Op 3: Vibhu cannot determine
Op 4: Both codes have the same execution time, so deliver any.

227.Q is an empty queue. The following operations are done on it:


ADD 5
ADD 7
ADD 46
DELETE
ADD 13
DELETE
DELETE
ADD 10
What will be the content of Q after these operations? Front is marked by (F) and Rear is marked by (R).
a) 10(R) 13(F)
b) 5(R) 10(F)
c) 13(R) 10(F)
d) 10(R) 5(F)

228.A is an empty stack. The following operations are done on it.


PUSH(1)
PUSH(2)
POP
PUSH(5)
PUSH(6)
POP
What will the stack contain after these operations?
a) 5 6
b) 1 6
c) 5 6
d) 1 5

229.Which of the following data structures may give overflow error, even though the current number of
elements in it is less than its size?
a) Queue implemented in a linear array
b) Queue implemented in a circularly connected array
c) Stack implemented in a linear array
d) None of these

230.As part of the maintenance work, you are entrusted with the work of rearranging the library books in a
shelf in proper order, at the end of each day. The ideal choice will be Bubble sort
A. Insertion Sort
B. Selection Sort
C. Heap Sort
D. None
231.To fully specify a singly linked linked-list, which of the following options is necessarily required?
a) Address of first element
b) Address of last element
c) Address of first and last element
d) All the above are insufficient
232.In which of the following scenarios will the code not work properly?
a) When the list has no elements
b) When the list has a single element
c) When the list has two elements
d) It will work well in all possible cases.

You might also like