You are on page 1of 147

1. Which of the following statements is/are true about optical fibres?

1. Optical fibre transports signal on the basis of total internal reflection principle.
2. Refractive index of core should be less than that of cladding.
3. Every beam which strikes the interface of core and cladding is reflected back.
TFF
TTT
TFT
FFF

2. Passage
Vijay wants to print the following pattern on the screen:
1
12
123
He writes the following program:
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
}
Question:
a. Statement 1
b. Statement 2 -ANS
c. Statement 3
d. Statement 4
e. Program does not have error
3. Passage:
Abhinav wants to find the largest number in a given list of 20 numbers. which of
the following options is an efficient approach to do this?
1) use bubble sort to sort the list in descending order and then print the first number
of the series.
2) use selection sort to sort the list in descending order and then print the first
number of the series
3) implement one iteration of selection sort for descending order and print the first
number in the series.-ANS
4) none of these

passage:
what is implied by the argument of a function?
question
1. the variables passed to it when it is called-ANS
2. the value it returns on execution
3. the execution code inside it
4. its return type

passage: there are two loops which are nested. this implies which one of the
following?
question
1.

two loops, one after the other

2.

two loops, one inside the other-ans

3.

one loop with two different iteration counts

4.

two loops with the same iteration count

Passage:
Mary is making a database of animals in a zoo and their properties. The possible
animals are dog, lion and zebra. Each one has as attributes is herbivorous, colour
and is nocturnal. She uses the object oriented programming paradigm for this.
How will she conceptualize the system?
Question
1.

class: Animal ; objects:dog, lion and zebra; data members:

is herbivorous, colour and is nocturnal-ANS

2.
class: Animal; objects: isHerbivorous, colour and isNocturnal; data
members: dog, lion and zebra
3.
classes: dog, lion and zebra; objects: Animal; data members:
isHerbivours,colour and IsNocturnal
4.

none of these

passage
what is space complexity of a program?
Question
1. amount of hard-disk space required to store the program
2. amount of hard-disk space required to compile the program
3. amount of memory required by the program to run-ans
4. amount of memory required for the program to compile

passage:
function MuFunc1(integer n)
{
return n*2
}
Function MyFunc2( integer n)
{
Print the value is n
}
Question:

Which of the given two functions can be categorized as procedure?


1. MyFunc1
2. MyFunc2
3. Both MyFunc1 and MyFun2
4. A function cannot be a procedure

Passage:
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
cariables:
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?

Question
1. Code B is better because variable names are shorter
2. Code A is better because the variable names are understandable and nonconfusing-ans
3. Code A will run correctly, while Code B will give an error.
4. Code B will run correctly, while code A will give an error.

Passage:
A derived class may inherit from the base class which of the following
(consider assumptions as in C++)

Question
1. Data members
2. Member functions
3. Constructors and destructors
4. Both data members and member functions-ans

Passage:
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 is equal front) is true
and neither is NULL, What do we infer about the linked list?

Question:
1. It has no elements
2. It has one elements-ans
3. There is an error
4. None of these

Passage:
Saloni writes the code for a function that takes as input n, an even integer and
calculates the sum of first n even natural numbers.

function sum( n )
{
If(n equals 2)

return 2
else
return {n + sum(n-2)}
end
}
She then calls the function by the statement1,sum(30). How many times will the
function sum be called to compute this sum?
Question
1. 1
2. 30
3. 15-ans
4. 16

Passage:
What is implied by the argument of a function?
Question
1. The variables passed to it when it is called-ans
2. The value it returns on execution
3. The execution code inside it
4. its return type

Passage:
For solving a problem, which of these is the first step in developing a working
program for it?
Question
1. writing the program in the programming language
2. writing a step-by-step algorithm to solve the program-ans
3. compiling the libraries required.
4. Code debugging.
Passage:
Integer a=40,b=35,c=20,d=10
Comment about the output of the following two statements:
Print a*b/c-d
Print a*b/(c-d)

Choose the correct answer


Assume the following precedence (high to low).operators in the same row have
the same precedence:
(.)
*/
+ AND
OR
For operators with equal precedence, the precedence is from left to right in
expression

Question
1. Differ by 80 ans
2. Same
3. Differ by 50
4. Differ by 160

Passage
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
Question
1. Bubble sort
2. Insertion sort-ans
3. Selection sort
4. Heap sort
Question
Which one of the following is not a program control instruction?
1. JMP
2. CALL ANS
3. RET
4. INC

QUESTION
For q relation R(A,B,C,D,E,F) given are functional dependencies on R
1. AB
2. CD
3. DBF
4. FC
Which of the following functional dependencies is not true for R?
1. DAF
2. CB
3. AFDB
4. FD

PASSAGE:
Integer num1,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

Question

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?
1. While(k++ < num1)
final+=num1
2. While(k++ < num2-1)
Final+=num1
3. While(k++ <=num2)
Final+=num1
4. While (k++ < num2)
Final+=num2

Passage:
Function modify(y,z)
{
y=y+1;
z=z+1;
return y z
}
Function calculator()
{
Integer a=5, b=10, c
C=modify(a,b);

Print a
Print space
Print c
}
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 calculate() is
executed?
1. 11/05/15
2. 10/05/15
3. 06/05/15
4. 05/05/15-ans

A programmer wants the program given below to print the largest number out of
three numbers entered by the user:
Int number1,number2,number3,temp;
Input number1,number2,number3;
If(number1>number2)
temp = number1
else
temp = number2
end if
if(??) // statement1
temp=number 3
end if

print temp
which of the following should be substituted in place of ?? in statement 1 in
the code?
1.number3>number2
2. number3>temp
3. number3<temp
4. number3>number1
Question
Which of the following is not a data type
1. Integer
2. Character
3. Boolean
4. Array-ans

Question
Nalanda wants to implement virtual functions. which of the following options
will she have to following in order to bring out the same?
1. Dynamic dispatching
2. Static dispactching
3. Static binding
4. Anonymous class

Question
How can the largest number in a list of twenty numbers be found?

1. Use bubble sort to sort the list in a descending order and then print the first
number of the series
2. Use selection sort to sort the list in a descending order and then print the first
number of the series
3. Implement one iteration of selection sort for descending order and print the first
number in the series-ans

4. None of the above

Question
What is the minimum numbers of stacks of size n required to implement a
queue of size n?
1. 1
2. 2
3. 3
4. 4

Question
Preeti writes a program in a 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?
1. Compiler-ans
2. Decompiller
3. Interpreter

4. Executer
5. Cross compiler

Question
Assume the following precedence (high to low). Operators in the same row have
the same precedence.
(.)
*/
+ AND
OR
The precedence is from left to right for the operators with equal precedence.
What will the output of the following code statements?
Integer a=50, b=25, c=5
Print a*b/c+c
1. 120
2. 125
3. 255
4. 250
Question
A programmer writes a program to find an element in the array A[5] With
elements 8 30 40 45 70. The program is run to find a number X, that is found
in the first iteration of binary search.what is the value of x?
1. 40-ans

2. 8
3. 70
4. 30
Question
How many nodes does a full binary tree with n non-leaf nodes contain?
1. log n
2. n + 1
3. 2n+1
4. 2n
Question
A programmer tries to debug a code of 10,000 lines. It is know 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?
1. Compile the entire code and check it line by line
2. Use an interpreter on the first 25 lines of code-ans
3. Compile the entire code and run it
4. None of the above can be used to debug the code.

Passage
function main()
{
integer i=0.7
static float m =0.7
if (m equals i)

printwe are equal


else if (m>i)
print I am Greater
else
printI am Lesser
}
Question:
What will be the output of the given code?
We are equal
I am greater ans
I am lesser
This code wil generate an error
Question;
Why is an algorithm designer concerned primarily about the run time and not the
compile time while calculating time complexity of an algorithm?
Run time is always more than the compile time
Compile time is always more than the run time
Compile time is a function of run time
A program needs to be compiled once but can be run several times-ANS
Question;
A integer X is saved as an unsigned 8-bit number 00001011.What is X?

22
11-ANS
10
None of the above

Question;
A full binary tree with n non leaf nodes contains

(logn) nodes
n+1 nodes
2n+1 nodes ANS
2n nodes
Question ;
Ravi is writing a program in C++, C++ uses the for keyword for loops . Due to
distraction ,Ravi writes gor intead of for.What will this result to?

The code will not compile-ANS


The code will give an error while in execution
The code may work for some inputs and not for others
It will create no problems
Question;
Which of the following sorting algorithms yields approximately the same worstcase and average-case running time behavior in O (n logn)?

Bubble sort and selection sort


Heap sort and merge sort ANS
Quick sort and radix sort
Tree sort and median-of-3 quick sort
Question;
In which of the following methods is sorting NOT possible?

Insertion
Selection
Exchange
Deletion-ANS
Passage

class brush

{
private:
integer size ,c
rcode
function getdata(){..}//Statement1
public:
integer name//Statement2
function putdata(){.}
}
fuction main
{
brush b1,b2
printb1.name //Statement 3
b2.getdata()//Statement 4
}
Question;
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 statements objectname.functionname and
objectname.datamembername, respectively. Which statement should be deleted
from the code to rectify the eroor in it?

Statement 1
Statement 2
Statement 3
Statement 4-ANS

Question;
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

Statement 1
Statement 2 ANS
Statement 3
Statement 4
No error

Question ;
Which of the following data structures may produce an overflow error even though
the current number of elements in its lower than its size?

A queue implemented in a linear array-ANS


A queue implemented in a circularly connected array
A stack implemented in a linear array

None of the above

Question;
Function main is the starting point of execution of a program. Which of the
following option shall help in making an executable program without the use of
main function in the program?

Any function can be made and marked as starting point using a language
dependent syntax

Two macros can be used. One to hold the name of a function and its working and
the other to call the first macro-ANS

Any program without a main function shall not do anything but can only
produce a blank screen

It is not possible to run a program without a main function in a program


Question;
A function in the base class is redefined in the inherited class. What is the term used
to describe the situation?

Inheritance
Overriding ANS
Overloading
Encapsulation

Qusetion;
The function given below takes a number n as the input and calculates the sum of
first n naural 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
}
n equals 1 ANS
n equals 2
n>=1
n>1
Question;
Which of the following algorithms is called the shortest-remaining-time-first
scheduling?

Preemptive short job first(SJF) scheduling ANS


Non-preemptive shortest job first(SJF) scheduling
Priority scheduling
Round robin scheduling

Question;
Which of the following option is not a necessary condition for Deadlock to occur?

Mutual exclusion
Hold and wait
No preemption
Circular wait
None of these-ANS

Question;
What will happen if some indentations are made in some statements of a code
written in C++?

Faster execution of code


Lower memory requirement for the code
Correction of errors in the code
Better readability of the code ANS
Passage:
function modify(a,b)
{
integer c,d=2
c=a*d+b
return c
}
function calculate()
{
integer a=5,b=20,c
integer d=10
c=modify(a,b);
c=c+d
print c
}

Question;

Consider the code given in the Passage. Assume that a and b are passed by the
value. What wil be the output of the program be when the function calculate() is
executed?

80
40 ANS
32
72

Question;
Trisha wants to use a data structure in which the cost of deleting, adding and
traversing its elements is the same and constant. Which of the following data
structures should she use?

B -Tree
AVL Tree
Queue
Stack

Question;
The program to print the larger of the two numbers entered by the user is given
below. Which of the following should be substituted in place of ?? in Statement 1
of the code to get the desired output?
int number1, number2
input number1, number2
if (??) //Statement1
print number1
else
print number2

endif
Option;
number1>number2 ANS
number2>number1
number2 equals number1
number1<=number2
Passage:
integer i,k,j,n =5
for i=n to 1 decreament 1
{
for j=n to i+1 decreament1
{
print blanks pace
}
for k=1 to ((2*i)-1) increament 1
{
print*
}
print end-of-line //takes the cursor to the next line
}
Question;
What will be the output when the given code is executed?
a)*****

****
***
**
*
b)*****
****
***
**
*-ANS
C)*****
****
*****
****
*****
d)

*
**
***
****
*****

e)*********
*******
*****
***

Question;
Consider the given conditions in regards to binary search performed on an named
MyArray1.
2.
3.

Beg >end
Beg<=end
MyArray[mid]!= item_to_be_searched
Which of the given conditions forms the termination condition of an iterative binary
search when the variables Beg,End and mid have their usual meanings?

Only 1 ANS
Only 2
Only 3
Both 2 and 3
All 1,2 and 3
Question;
Assume the following procedure (high,low). Operators in the same row have the
same procedure.
(.)
*/
+AND
OR
The precedence is from the left to right in the expression for the operators with the
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)

the outputs differ by 80- ANS


the outputs are the same
the outputs differ by 50
the outputs differ by 160

From pg num:37 to 46
Passage
function modify(y,z)
{
z=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
}

Question;
Consider the code given in the passage.assume thata and b are passed by
value .what will the output of the program be when the function calculate () is
executed?

11/05/15
10/05/15
06/05/15
05/05/15 (ans)

Question
How many nodes in a tree with n nodes have no ancestors?

0
1
2
Log n(ans)

Question
A programmer wants the program given below to print the largest number out of
three numbers entered by the user .
int number 1,number2,number3,temp;
input number1,number 2,number3;
if(number1>number2)
temp=number1
else
temp=number2
end if
if(??)//statement1

temp=number3
end if
print temp
which of the following should be substituted in place of ?? in statement 1 in
the code?

number3>number 2
number3>temp (ans)
number3<temp
number3>number1

question
A sorting mechanism uses the binary tree concept such that any number in the
tree is larger than all the numbers in the sub-tree below it . what is this method
called?

Selection sort
Insertion sort
Heap sort (ans)
Quick sort

Question
Which of the following implies that there are two loops that are nested?

Two loops, one after the other


Two loops , one inside the other (ans)
One loop with two different iteration counts
Two loops with the same iteration count

Question

Which of the following can be inherited by a derived class from a base class?

Data members
Member functions
Constructors and destructors
Data members and member functions

(ans)

Question
Which of the given function prototypes can be considered to be overloaded (no
ambiguity)?
a.function myfunc (integer num, float me)// does not return anything
b.function myfunc(integer num, double me) //does not return anything
c.function myfunc(character num,float me) //does not return anything
d.function myfunc(integer num, float me )//returns an integer

A and B
A,B and C
A,C and D
B,C and D
Both 2 and 4

Question
Which of the following describes a tree ?
An unconnected graph

A connected graph
A connected acyclic graph
A complete graph

(ans)

Question
How many nodes does a full binary tree with n non leaf nodes contain?

log n
n+1
2n+1
2n

(Ans)

Question
What is the minimum number of stacks of size n required to implement a
queue of size n?

1
2 (ans)
3
4

Which of the following options is an exception to being a part of composite data


types?
Union
Array
Structure
Stack (ans)

Question
Two programmers independently write a program to find the mass of one mole
of water , that includes the masses of hydrogen and oxygen .

The first programmer defines the variables as:


integer hydrogen , oxygen , water //code A
the second programmer defines three quantities as:
integer a, b, c //code B
which of the two is a better programming practice and why?

Code B is better because variable names are shorter.


Code A is better because the variable names are understandable and nonconfusing . (ans)
Code A would run correctly while code B would give an error.
Code B would run correctly while Code A would give an error

Question
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
sum Row1[n]= A[n] +A[n][2]
end
Y writes the code (Code B) as follows:
sumRow1[0] =A[0][1] +A[0][2]
sumRow1[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?
Code A would execute faster than Code B.
Code B would execute faster than Code A. (ANS)

Code A is logically incorrect .


Code B is logically incorrect.

Question
Which of the following abstract data type can be used to represent a many- tomany relation?

Tree
Stack
Graph (ans)
Queue

Question
For which of the following purposes is the construct given below used?
if (condition) then A else B

decision making (ans)


iteration
recursion
object-oriented programming

question :
A librarian has to rearrange the library books on a shelf in aproper order at the
end of each day. Which of the following sorting techniques should be the
librarians ideal choice?

Bubble sort
Insertion sort (ans)
Selection sort
Heap sort

Question:
W hich of the following sorting techniques has the worst case functioning time
less than O(n*n)?

Heap sort
Quick sort
Insertion sort
Selection sort

Passage:
Stack is useful for implementing.

Radix search
Breadth first search
Recursion (Ans)
None of these

Question:
What is the term given to the variable whose scope is beyond all the scopes
.i.e..,it can be accesses by all the scopes ?

Universal variable
Global variable (ans)
External variable
Auto variable
Both 2 and 3

Question:
Yashi wants to implement priority queues using arrays. What is the minimum
number of arrays that she should use to serve the purpose?
1
2 (ans)

3
4
Passage:
For solving a problem which of these is the first step in developing a working
program for it?

Writing the program in the programming language.


Writing a step by step algorithm to solve the problem.
Compiling the libraries required .
Code debugging.

(ans)

Passage:
How can a call to an overload function to ambiguous?
By misspelling the name .
There might be two or more functions with the same name .
There might be two or more functions with equally appropriate signatures
(ans)
None of these

While calculating time complexity of an algorithm , the designer concerns


himself /herself primarily with the run time and not the compile time .why?

Runtime is always more than compile time .


Compile time is always more than run time.
Compile time is a function of runtime.
A program needs to be compile once but can be run several times.

(ans)

Question :
Which of the following options is an exception to being a part of composite data
types?
Union
Array
Structure

Stack

(ans)

Question:
Which of the following options is both necessary and sufficient condition for
preparing binary search?
Array must be sorted,direct access to the middle element should be
provided. (ans)
Array should be in ascending order .
Direct access to the middle element must be provided.
Array should be sorted.

Question:
Which of the following statement is not true in the context of anonymous union
data type?

It is a union that does not have any name.


It is not followed by a declaratory.
It defines an unnamed object.
It defines a data type .

(ans)

Page no:47-56
Why is an algorithm concerned primarily about the run time and not the compile
time while calculating time complexity of an algorithm?

Run time is always more than the compile time


Compile time always more than the run time
Compile time
is a function of run time
A program needs to be compiled but once can be run several times (ans)

Two programmers independently write the program to find the mass of one mole
of water, that includes the masses of hydrogen and oxygen.

The first programmer defines the variables as:


Integer hydrogen , oxygen ,water // code A
The second programmer defines the quantities as:
Integer a, b, c // code B
Which one of a two is better and why?
Code B is better because variable names are shorter
Code A is better because variable names are understandable and nonconfusing (ans)
Code A would run correctly while code B would give an error
Code B would run correctly while code A would give an error

Parthiv has included several classes and their several objects in his projects.Now
he wants to use something that will hold all these objects(of different
classes).which one of the following option provides him with the best alternate?

Store them in database


Final class
Generic class (ans)
Anonymous class

In a linear list of elements , a deletion can be made from one end (front) and an
insertion can be made at the other end(rear).what is this linear list known as?

Queue (ans)
Stack
Tree
Branch

What is the first step for developing working program to solve a problem?
To write the program in the programming language
To write a step-by-step algorithm to solve the problem (ans)

To compile the required libraries


To debug the code

Every element of an data structure has an address and a key associated with it. A
search mechanism deals with the two or more values assigned to the same
address by using the key . what is this search mechanism?

Linear search
Binary search
Hash code search (ans)
None of the above

How many nodes does a complete binary tree with 5 levels have , if the root is
considered to be at 1?

16
25
63
31 (ans)

Passage
Union myunion
{
Structure mystructure
{
Integer m;
Float n:
Character 0
} mystr
Integer p;

}myunion

Given that the size of integer is 2 units , float is 4 units character is 1 unit , what
will be the amount of memory occupied by the myunion object?

2 units
6 units
7 units
9 units (ans)

A program to be solved is broken into the sequence of smaller of sub-problems


unit a stage where the sub-problem can be easily solved .what is this design
approach called?
Top down approach (ans)
Bottom up approach
procedural programming
None of the above

In which one of the following method is sorting not possible?

Insertion
Selection
Exchange
Deletion (ans)

Which one the following gives the maximum nodes at level I of a binary
tree ?

2I-1 (ans)
3I-1
2I
2I-1

The function given below takes a number n as the input and calculate the sum
of first n natural numbers . which one 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
}
N equals 1 (ans)
N equals 2
n>=1
n>1

what is implied by the argument of a function?

The variables passed to the function when it is called (ans)


The value that the function returns on execution
The execution code inside the the function
Return type of the function

Which one of the following implies that there are two loops that are nested?
Two loops , one after another

Two loops , one inside the another (ans)


One loop with two different iteration count
Two loops with the same iteration count

Passage
Fun mybinarysearch(array arr , integer low , integer high , integer item)
{
If( low >high )
{
Return -1
}
Integer mid =(low + high )/2
If(arr[mid]= equals item)
{
Return mid
}
Elseif (arr[mid]>item)
{
Return
}
Else
{
Return
}

Harshul uses the given code to implement the binary search respectively . find
the statement that will replace missing statement 1 in the given code such that it
works efficiently ?

Mybinary search( arr , low +1 , mid -1 , item)


Mybinary search( arr , mid +1 , high -1 , item)
Mybinary search( arr , mid+1 , high, item)
Mybinary search( arr, low, mid-1 , item) (ans)

In an implementation of a linked list , each node contain data and address .


which of the following can the address field possibly contain?

Address of the next node in sequence (ans)


Its own address
Address of the last node
Address of the first node

Which one of the following statements is TRUE about the variable?

A variable cannot be used before it is declared (ans)


A variable cannot be used after it is declared
A variable cannot be used in the function it is declared in
A variable can always be used
The program to print the larger of the two numbers entered by a user is
given below . which one of the following should be replaced in place of
?? in statement 1

Int number1,number2
Input number1,number2

If(??)
print number1
else
print number2
end if
number1>number2 (ans)
number2>number1
number1=number2
number1<=number2

A programmer writes a program to find an element In the array A[5] with the
elements : 8 30 40 45 70 . the program is run to find the number x that is
found in the first iteration of binary search . what is the values of x?

40 (ans)
8
70
30

Passage
Class brush
{
Private:
Integer size , c
Rcode
Function getdata ()

Public:
Integer name
Function putdat ()
}
Function main
{
Brush b1, b2
Printb1.name
B2.getdata
}
Refer to the pseudocode given in the passage . this code is similar to that in c++
and ic self-explanatory . an accessible member function and a data member for
an object accessed by the statements object name .function name and
objectname.datamembername respectively . which statement should be deleted
from the code to rectify the error in it ?

Statement 1
Statement 2
Statement 3
Statement 4 (ans)

How can a call to an overloaded function be ambiguous ?


The name of the function might have been misspelled
There might be two or more function with the same name
There might be two or more functions with equally appropriate signatures
(ans)
Nine of the above

The function given below takes the number n as the input and calculate the
sum of first n natural number . which one of the following statement should be
inserted in place of ?? to get the required output?
Function sum(n)
{
If(??)
Return 1
Else
Return (n+sum(n-1))
End
}

N equals 1
N=2
n>=1
n>1

passage
function preordertraverse (node)
{
Printnode
If (condition x)
{preordertransverse(node left)}
If (condition y)
{preordertransverse(node right)}
Return }

Consider a three binary implementations . the root address is stored in the


variable root . the address of the node and its right and left child nodes can be
accessed using the statements given below
Node->value
Node ->right
Node->left
A programmer writes the function given in the passage to do a preorder
transversal of the tree what are the condition x and y ?
Condition x:node-> left is not equal (ans)
Condition y:node-> right is not equal
Condition x:node->right is not equal
Condition y:node->left is not equal
Condition x:node-> left is equal
Condition y:node-> right is equal
Condition x:node->right is equal
Condition y:node->left is equal

What is the output of the program given below?


Integer i=0,j
While (i<2)
{
J=0;
While (j<=3*i)
{
Print j
Print blank space
j=j+3

}
Print end-of-line //takes the cursorto the next line
I=i+1
}
a) 0
0 3 (ans)
b) 0 3
036
c) 0
036
0369
d) 0 3 6
0369
0 3 6 9 12

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 (ans)

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. (ans)


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.

An integer X is saved as an unsigned 8-bit number 00001011.what is X?


a) 22
b) 11 (ans)
c) 10
d) None of the above

Which of the following sorting algorithms yields approximately the same


worst-case and average-case running time behavior in O (n logn)?
a)
b)
c)
d)

Bubble sort and selection sort


Heap sort and Merge sort (ans)
Quick sort and Radix sort
Tree sort and Median-of-3 Quick sort

A programmer writes a sorting algorithm that takes different amount of


the time to sort two different lists of equal size. what is the possible
difference between the two lists?
a) All number in one lists 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.(ans)
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.

What will the output of the following pseudo code statements be?
(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 the data types have enough range to accommodate any number.if two
different datatypes are operated upon,the result assumes the data type that
is more expressive.)
Integer a=456,b,c, d=10
b= a/d
c= a-b
print c
a) 410
b) 410.4
c) 411.4
d) 411(ans)

The function given below takes a number n as the input and calculates
the sum of the 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)
b)
c)
d)

n equals 1 (ans)
n equals 2
n>=1
n>1

In which of the following situations can a constructor be invoked?


a)
b)
c)
d)

When an object is created(ans)


When an object is assigned the value 0
Only at the end of the code
When the scope of the object is over

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)
b)
c)
d)

Integer
Boolean(ans)
Float
Character

A sorting mechanism uses the binary tree concept such that any number in
the tree is larger than all the numbers in the sub-tree below it. What is this
method called?
a)
b)
c)
d)

Selection sort
Insertion sort
Heap sort (ans)
Quick sort

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. (ans)


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.

A programmer writes a sorting algorithm that takes different amount of


the time to sort two different lists of equal size. what is the possible
difference between the two lists?
a) All number in one lists 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.(ans)
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.

Refer to the pseudo code 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?
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
}
a) statement 1`
b)statement 2
c)statement 3
d) statement 4(ans)
How many nodes does a full binary tree with n leaves contain?
a)
b)
c)
d)

2n+1 nodes
Log2n nodes
2n-1 nodes (ans)
2n nodes

Which of the following data structures may produce an overflow error even
though the current number of elements in it is lower than its size?
a)
b)
c)
d)

A queue implemented in a linear array (ans)


A queue implemented in a circularly connected array
A stack implemented in a linear array
None of the above

The function given below takes a number n as the input and calculates
the sum of the 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)
b)
c)
d)

n equals 1 (ans)
n equals 2
n>=1
n>1

A programmer writes a code snippet in which a set of three lines occurs ten
times in different parts of the program. When programming concept should
be used to shorten the code length?
a)
b)
c)
d)

For loops
Functions (ans)
Arrays
Classes

Refer to the pseudo code 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, what can be
inferred from this code?
Class rocket

{
Pivate:
Integer height,weight
Public: //statement 1
function input(int a , int b)
{
height=a;
weight=b;
}
}
function main ()
{
Rocket rocket1,rocket2
}
a) rocket is a class with rocket 1 and rocket 2as its objects. With
height and weight as its attributes.(ans)
b) rocket is a class with rocket 1 and rocket 2as its objects. With
height and weight as its objects.
c) rocket is a class with rocket 1 and rocket 2 height and weight
as its attributes.
d) rocket is a class with rocket 1 and rocket 2 height and weight
as its objects.
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(ans)

c) Float
d) Character
Two programmers independently write a program to find the mass of one
mole of water that includes the masses of hydrogen and oxygen.
The first programmer defines the variables as:
Integer hydrogen, oxygen, water//code A
The second programmer defines three quantities as:
Integer a, b, c //code B
Which of the two is a better programming practice and why?
a) Code B is better because variable names are shorter .
b) Code A is better because the variables names are understandable and
non-confusing.(ans)
c) Code A would run correctly while code B`would give an error.
d) Code B would run correctly while Code A would give an error.

A stack is implemented as a linear array A[0N-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
{
Printunderflow

}
Return top
}
Which of the following should substitute the condition X?
a)
b)
c)
d)

Top<N-1
Top<N
Top>1
Top>=0(ans)

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(ans)
c)overloading
d) encapsulation
In which of the following situations can a constructor be invoked?
a)
b)
c)
d)

When an object is created(ans)


When an object is assigned the value 0
Only at the end of the code
When the scope of the object is over

Consider a binary tree implementation. The root address is stored in the


variable root. The address of a node is given in the variable node. The value
of the node and its right and left child notes can be accessed using 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?


Function preordertraverse(node)
{
Print node ->value
If (condition x)
{preordertraverse(node->left)}
If (condition Y)
{preordertraverse(node->right)}
Return
}
a)condition X:node->left is not equal
condition Y:node->right is not equal(ans)
b) condition X:node-> left is not equal
condition Y:node-> right is not equal
c) condition X:node->left is equal
condition Y:node->right is equal
d) condition X:node->right is equal
condition Y:node->left is equal
Which of the following implies that there are two loops that are nested ?
a)
b)
c)
d)

Two loops,one after the other


Two loops,one inside the other(ans)
One loop with two different
iteration counts
Two loops with the same iteration count

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)
b)
c)
d)

Integer
Boolean(ans)
Float
Character

A programmer wants the program givren below to print the largest number out
of three numbers entered by the user.
int number1, number2, number3, temp;
input number1, number2, number3;
if(number1>number2)
temp=number1
else
temp=number2
end if
if(??)//Statement 1
temp=number3
end if
print temp
Which of the following ashould be substituted in place of ?? in the ststement 1
in code?
a)
b)
c)
d)

number3>number2
number3>temp (ans)
number3<temp
number3>number1

Which of the following statements is TRUE about a variable ?


a) A variable cannot be used before it is declared (ans)
b) A variable cannot be used after it is declared
c) A variable cannot be used in the function it is declared

d) A variable can always be used

The programmer mistakenly writes gor instead of the keyword for used in
loops, while writing a program in C++. What will this result in?
a)
b)
c)
d)

The code would not compile. (ans)


The code would give an error while execution.
The code may work for some inputs and for the other .
The code would not create any problem.

Why is an algorithm designer concered primarily about the run time and not the
compile time while calculating time complexity of an algorithm?
a)
b)
c)
d)

Run time is always more than the compile time.


Compile time is always more than the run time.
Compile time is a function of run time.
A program needs to be compiled once but can be run several times. (ans)

A programmer writes a sorting algorithm that takes different amount 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 order of numbers with respect to the magnitude in the two lists has
different properties. (ans)
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.
A programmer prepares a questionnaire with true or false type of questions.
He wants to define a data type that stores the response of the candidate for the
questions. Which of the following is the most suited data type for this purpose?
a)
b)
c)
d)

Integer
Boolean
Float
Character

Why is an algorithm designer concered primarily about the run time and not the
compile time while calculating time complexity of an algorithm?
a)
b)
c)
d)

Run time is always more than the compile time.


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

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
}
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.datamember name, 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

Which of the following gives the maximum number of the nodes at level I of a
binary tree?
a)
2I-1
b)
3I-1
c)
2I
d)
2I 1
Which of the following atatements is TRUE about a breadth first search?
a) Beginning from a node, all the adjacent nodes are traversed first. (ans)
b) Beginning from a node, each adjacent node is fully explored before
traversing next adjacent node.
c) Beginning from a node, the nodes are traversed in cyclic order.
d) None of the above.
The programmer prepares a questionnaire with true or false type of questions.
He wants to define a data type that stores the response of the candidate for the
questions. Which of the following is the most suited data type for this purpose?
a) Integer
b) Boolean
c) Float
d) Character

Why is an algorithm designer concered primarily about the run time and not the
compile time while calculating time complexity of an algorithm?
a)
b)
c)
d)

Run time is always more than the compile time.


Compile time is always more than the run time.
Compile time is a function of run time.
A program needs to be compiled once but can be run several times. (ans)

A programmer is making a database of animals in a zoo along with their


properties. The possible animals are dog, lionand zebra. Each one has attribute

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 (ans)
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) None of the above

In an implementation of a linked list, each node contains data and address.


Which of the following can the address field possibility contain?
a)
b)
c)
d)

Address of the next node in sequence


Its own address
Address of the last node
Address of the first node

A programmer prepares a questionnaire with true or false type of questions.


He wants to define a data typwe that stores the response of the candidates for the
questions. Which of the following is the moist suited data type for this
purpose?
a)
b)
c)
d)

Integer
Boolwan (ans)
Float
Character

Two programmers independently write a program to find the mass of one mole
of water, that includes the masses of oxygen and hydrogen.
The first programmer defines the variables as:

Integer hydrogen,oxygen,water // Code A


The second programmer defines three quantities as:
Integer a,b,c // Code B
Which of the two is a better programming practice and why?
a) Code B is better because variable names are shorter.
b) Code A is better because the variables names are understandable and nonconfusing. (ans)
c) Code A would run correctly while Code B would give an error.
d) Code B would run correctly while Code A would give an error.

What is the first step for developing a working program to solve a problem?
a)
b)
c)
d)

To write the program in the programming language.


To write a step-by-step algorithm to solve the problem.
To compile the required libraries.
To debug the code.

Which of the following algorithm design techniques is used in the quick short
algorithm?
a)
b)
c)
d)

Dynamic programming
Back tracking
Divide and conquer
Greedy search

How can a call to an overloaded function be ambiguous?


a)
b)
c)
d)

The name of the function might have been misspelled


There might be two or more functions with the same name
There might be two or more functions with equally appropriate signatures
None of the above

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
insertedin place of ?? to get the required output?
function sum(n)
{
if(??)
return 1
else
return (n+sum (n-1))
end
}
a)
b)
c)
d)

n equals 1 (ans)
n equa;s 2
n>=1
n>1

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)
b)
c)
d)

For loops
Functions
Arrays
Classes

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


Which of the following can be inherited by a derived class from a base class?
a)
b)
c)
d)

Data members
Member functions
Constructor and destructor
Data members and member functions

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)
b)
c)
d)

Compile the entire code and check it line by line.


Use an interpreter on the first 25 lines of code. (ans)
Compile the entire code and run it.
None of the above can be used to debug the code.

Which of the following statements is TRUE about a breadth first search?


a) Beginning from a node, all the adjacent nodes are traversed first (ans)
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

How can a largest number in a list of twenty numbers be found?


a) Use bubble sort to sort the list in a descending order and then print the first
number of the series
b) Use selection sort to sort the list in a descending order and then 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 (ans)
d) None of the above

What is the output of the program given below?


Integer i= 0,j
While(i<2)
{
J=0;
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
0 3(ans)
b) 0 3
036
c) 0
036
0369
d) 0 3 6
0369
0 3 6 9 12

Assume the following precedence (high to low). Operaters in the same row
have the same precedence
(.)

*/
+AND
OR
The precedence is the from the 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)
b)
c)
d)

The outputs differ by 80.(ans)


The outputs are the same.
The outputs differ by 50.
The outputs differ by 160.

In which of the following situation can a constructor be invoked?


a)
b)
c)
d)

When an object is created


When an object is assigned the value 0
Only at the end of the code
When the scope of the object is over (ans)

What will happen if some indentations are made in some statements of a


code written in C++?
a)
b)
c)
d)

Faster execution of the code


Lower memory requirement for the code
Correction of errors in the code
Better readability of the code (ans)

Which of the following can be inherited by a derived class from a base


class?
a)
b)
c)
d)

Data members
Member functions
Constructors and destructors
Data members and member function (ans)

How many nodes does a full binary tree with n leaves contain?
a)
b)
c)
d)

2n+1 nodes
Log2n nodes
2n-1 nodes (ans)
2n nodes

A sorting algorithm traverses through a list, comparing adjacent


elements and switching them under certain conditions. What is the sorting
algorithm called?
a)
b)
c)
d)

Insertion sort
Heap sort
Quick sort
Bubble sort (ans)

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)
b)
c)
d)

The code would not compile.(ans)


The code would give an error while execution
The code may work for some inputs and not for the others
The code would not create any problem

Which of the following sorting algorithms yields approximately the same


worst-case and average-case running time behavior in O (n logn)?
a)
b)
c)
d)

Bubble sort and selection sort


Heap sort and merge sort (ans)
Quick sort and radix sort
Tree sort and median-of-3 quick sort

A programmer writes a program to find an element in the array A[5]


with the elements: 8 30 40 45 70. The program is run to find a number X,
that is found in the first iteration of binary search. What is the value of
X?
a) 40 (ans)
b) 8
c) 70
d) 30

Which of the following is the lowest level format to which the computer
converts a program in a higher language before execution?
a)
b)
c)
d)

English code
Machine code (ans)
Assembly language
System language

What is implied by the argument of a function?


a)
b)
c)
d)

The variables passed to the function when it is called (ans)


The value that the function returns on execution
The execution code inside the function
Return type of the function

Which of the following best describes the space complexity of a program?

a)
b)
c)
d)

Amount of hard disk space required to store the program


Amount of hard disk space required to compile the program
Amount of memory required for the program to run (ans)
Amount of memory required for the program to compile

Which of the following sorting algorithms yields approximately the same


worst-case and average-case running time behavior in O (n logn)?
a)
b)
c)
d)

Bubble sort and selection sort


Heap sort and merge sort (ans)
Quick sort and radix sort
Tree sort and median-of-3 quick sort

For which of the following is the stack implementation useful?


a)
b)
c)
d)

Radix search
Breadth first search
Recursion (ans)
None of the above

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)
b)
c)
d)

1
30
15 (ans)
16

A developer writes the program given below to print the sum of the first five
whole numbers (04). 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)
b)
c)
d)

No error, the program is correct


Statement 1
Statement 4 (ans)
Statement 6

What will happen if some indentations are made in some statements of a


code written in C++?
a)
b)
c)
d)

Faster execution of the code


Lower memory requirement for the code
Correction of errors in the code
Better readability of the code (ans)

Which of the following describes a tree?

An unconnected graph
A connected graph
An connected acyclic graph--A
A complete graph

Which of the following can be inherited from derived class to base class?

Data members
Member functions
Constructors and destructors
Data members and member functionsA

What does function overloading imply?


Many function definitions with same name, same arguments and different
return types
Many function definitions with the same name and different arguments-A
Many functions definitions with the same name and same arguments
None of the above.

A programmer mistakenly writes got instead of the keyword for used in


loops, while writing a program in c++ . What will this result in?
1.The code would not compile.--A
2.The code would giver an error while execution.
3.The code may work for some inputs and not for others.
4.The code would not create any problem.
A librarian has to rearrange the library books on a shelf in p0roper order at the
end of each day. Which of the following sorting techniques should be the
librarians ideal choice?

1. Bubble sort
2.Insertion sort---A
3.Selection sort
4.Heap sort
A programmer is making a database of animals in zoo along with their
properties. The possible animals are dog, lion and zebra. Each one has attributes
as herbivores, color and nocturnal. The programmer uses the object-oriented
programming paradigm for this. How will the system be conceptualized?
1.Class: Animal, objects: dog, lion and zebra; data members; herbivores, color
and nocturnal---A
2.Class: Animal; objects: herbivorous, color and nocturnal; data members : dog,
lion and zebra
3.Classes: dog, lion and zebra; objects: Animal; data members: herbivorous,
color and nocturnal
4.None of the above
Which of the following implies that there are two loops that are nested?
1.Two loops, one after the other
2.Two loops, one inside the other--A
3.One loop with two different iterations counts
4.Two loops with same iteration count

A destructor may be invoked in which of the following situations?


1.When the object is created
2.When the object is assigned value 0
3.Only at the end of the code
4.When the scope of the object is over--A

What is space complexity of a program?


1.Amount of hard-disk required to store the program
2.Amount of hard disk space required to compile the program
3.Amount of memory required by the program to run--A
4.Amount of memory required for the program to compile

While calculating time complexity of an algorithm, the designer concerns


himself/herself primarily with the runtime and not the compile time. Why?
1.Run time is always more than the compile time.
2.Compile time is always more than run time.
3.Compile time is a function of run time,
4.A program needs to be compiled once but can be run several times.--A

Which of the following sorting algorithms yield approximately the same worstcase and average-case running time behavior in 0(n log n)?
1.Bubble sort and selection sort.
2.Heap sort and merge sort.--A
3.Quick sort and radix sort.
4.Tree sort and median of 3 quick sort.

Srujan writes a sorting algorithm. The algorithm takes different amount to sort
two different lists of equal size. What is the possible difference between the two
lists?
1.All number in one list are more than 100, while in the other are less than 100.
2.The ordering of numbers with respect to magnitude in two list has different
properties.--A
3. One list has all negative numbers, while the other has all positive numbers.
4.One list contains 0 as an element, while the other does not.

Consider the following pseudo- code


Class brush
{
Private:
Integer size, colorcode

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
}
Deleting which line will correct the error in the code?
1.Statement 1
2.Statement 2
3.Statement 3
4.Statement 4--A
How can a call to an overloaded function be ambiguous?
1.By misspelling the name
2.There might be two or more functions with same name--A
3.There might be two or more functions with equally appropriate signatures
4.None of these
Which one of the following is the lowest level format to which the computer
converts a higher language program before execution?
1.English code
2.Machine code--A
3.Assembly language
4.System language

Tanuj writes the code for a function that takes as input n and calculates the sum
of first n natural numbers.
Function sum (n)
{
If (??)
Return 1
Else
Return (n+sum(n-1))
End
}
Fill in?? In the code.
n equals 1--A
n equals 2
n>=1
n<1

consider the following pseudo code


class rocket
{
Private:
Integer height, weight
Public: //statement 1
Function input (inta, intb)
{

height =a;
weight=b;
}
}
Function main()
{
Rocket, rocket 1, rocket2
}
What can we infer from this code?

Rocket is a class with rocket 1 and rocket2 as its objects. Height and
weight are attributes of rockets.--A

Rocket is a class with rocket1 and rocket2 as its attributes. Height and
weight are objects of the class rocket.

Rocket is a class with rocket1, rocket2, height and weight as its attributes,

Rocket is a class with rocket1, rocket2. Height and weight as its objects.

Himanshu wants to write a program to print the larger of the two inputted
number. He writes the following code:
Int number1,number2
Input number1,number 2
If(??) //statement 1
Print number 1
Else
Print number 2
End if

Fill in the ?? in statement 1.

Number 1> number 2--A


Number2 > number 1
Number 2 equals number 1
Number 1<=number 2

A stack is implemented as a linear array A{0N-1}. Noor writes the following


functions for popping an element from the stack.
Function POP (top,N
{
If(x)
{
Top=top-1
}
Else
{
Print underflow
}
Return top
}
Fill in the conditions X

Top<N-1
Top
Top>1
Top>=0--A

Srishti writes a program to find an element in the aray A{5} with the following
elements in order: 8 30 40 45 70. She runs the protam to find a number X. X is
found in the first itertation fo binary search. What is the value of X?

40--A
8
70
30

A variable cannot be used

Before it is declared--A
After it is declared
In the function it is declared in
Can always be used

Shashi writes a program in c++ and passes it on to pankaj. Pankaj does some
indentation in some statements of the code. What will this lead to?

Faster execution
Lower memory requirement
Correction of errors
Better readability--A

Stuti is making a questionnaire of true- false questions. 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?

Integer
Boolean--A
Float
Character

Mary is making a database of animals in a zoo and their properties . The possible
animals are dog. Lion and zebra. Each one has an attributes is herbivorous,
color and is Nocturnal. She uses the object oriented programming paradigm for
this. How will she conceptualize the system?
Class: animal: objects: dog, lion and zebra; data members : is herbivorous,
color and isNocturnal--A
Class animal; objects; isherbivorous,color and isNocturnal; data
members : dog, lion and zebra
Classes: dog,lion and zebra; objects; animal; data members:
isHerbivorous, color and isNocturnal
None of these

Sharmili wants to make a program to print all the sum of all cubes, where the
values of the cubes go from 0 to 100. She writes 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
Does this program have an error? If yes, which statements will you modify to
correct the program?
Statement 1

Statement2--A
Statement 3
Statement 4

Sorting is not possible by using which of the following methods?

Insertion
Selection
Exchange
Deletion--A

The algorithm design technique used in the quick sort algorithm is

Dynamic programming
Back tracking
Divide and conquer--A
Greedy search.

Which of the following algorithims is called the shortest-remaining time first


scheduling?

Preemptive shortest job first(SJF) scheduling


Non preemptive shortest job first(SJF) scheduling
Priority scheduling
Round robin scheduling.

Which of the following options is not a necessary condition for deadlock to


occur?

Mutual exclusion
Hold and wait
No preemption
Circular wait

None of these

Which one of the following is the lowest level format to which the computer
converts a higher language program before execution?

English code
Machine code--A
Assembly language
System language

Ravi is writing a program in c++. C++ uses the keyword for loops due to
distraction. Ravi writes gor instead of for. What will this result to?

The code will compile.--A


The code will give an error while in execution.
The code may work for some inputs and not for others.
It will create no problems.

A complete binary tree with 5 levels has how many nodes?(Root is level 1)

15
25
63
31--A

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


PUSH(1)
PUSH(2)
POP
PUSH(5)

PUSH(6)
POP

Ravi is writing a program in c++. C++ uses the for keyword for loops. Due to
distractions, ravi writes gor instead of for. What will this result to?

The code will not compile--A


The code will give an error while in execution,
The code may work for some inputs and not for others.
It will create no problems.

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

Mary is making a database of animals in a zoo and their properties.The possible


animals are dog,lion and zebra.Each one has as attributes is Herbivorous,colour
and is Nocturnal.She uses object oriented programming paradigm for this.How
will she conceptualise the system?
Class:Animal; objects:dog,lion and zebra;data
members:isHerbivorous,color and isNocturnal (ans)

Class:Animal;objects:isHerbivorous,color and isNocturnal; data


members: dog,lion,zebra
Class:dog,lion,zebra objects:Animal; data members:isHerbivorous,
color and isNocturnal
None of these
Maximum number of nodes on level I of a binary tree is which of the following?
(root is level 1)

2^(I-1) (ans)
3^(l-1)
2^(l)
2^(I)-1

Afzal writes a piece of code where a set of 3 lines occur around 10 times in
different parts of the program.What programming concept can he use to shorten
his program code length?

Use for loops


Use functions(ans)
Use arrays
Use classes

A variable cannot be used

Before it is declared(ans)
After it is declared
In the function it ids declared in
Can always be used

Pragya sells footballs. She has a large container to store footballs which is closed
from below.Footballs are piled one on top of other in a box. Where new balls are
supplied,Pragya puts the balls in the box from the top.When a customer buys a
ball she delivers it at the top of the puile to the customer.Each ball has a
code.She wants to store the ball codes in a data structure to keep track of her
inventory.What data structure must she use?
Queue
Stack(ans)

Array
Graph
In breadth-first search,which of the following options is truie?
Beginning from a node , first all its adjacent nodes are traversed(ans)
Beginning from a node , each adjacent node is fully explored before
traversing the next
Beginning from a node, nodes are traversed cyclically
None of these
Consider a binary tree representation.The root address is is stored in the variable
root. Given the address of a node in variable node.Its value ,right and the root
child node address can be accessed using following atatements respectively.node
-> value, node->right, node->left. Srikanth writes the following function to do a
preorder traversal of the tree.
Function preordertraverse(node)
{
Print node->value
If (condition X)
{preordertraverse(node->left)}
If (condition Y)
{preordertraverse(node->right)}
Return
}
Condition X: node->left isnotequal null
Condition Y :node-> right isnotequal null (ans)
Condition X:node-> right isnotequal null
Condition Y: node->left isnotequal null

Condition X: node->left isequal null


Condition Y: node->left isequal null

Condition X:node-> right isequal null


Condition Y: node->left isequal null

Abhinav wants to find the largest number in a given list of 20 numbers.which


option is an efficient approach to do this?

Use bubble sort to sort the list in descending order and then print first
number of the series

Use selection sort to sort the list in descending order and print first
number in the series

Implement one iteration of selection sort for descending order and print
first number of the series(ans)

None of these

Shashi writes a program in c++ and passes it on to Pankaj. He does some


indentation in some lines of the code. What this will lead to?

Faster execution
Lower memory requirement
Correction of errors
Better readability(ans)

Himanshu wants to write a program to print the larger of 2 inputted numbers.He


writes the following code:
Int num1,num2

Input num1,num2
If(??)// statement 1
Print num1
Else
Print num2
Endif
Fill in the (??)

Num1>num2(ans)

Num2>num1

Num2=num1

Num1<=num2
In which area of a class are data and function directly accessible outside the
class?

Public(ans)
Private
Protected
None of these

Shashi writes a program in c++ and passes it on to Pankaj. He does some


indentation in some lines of the code. What this will lead to?

Faster execution
Lower memory requirement
Correction of errors
Better readability(ans)

Every element of a data structure has an addresss an a key associated with it.A
search mechanism deals with 2 or more values assigned to the same address by
using the key. What is this search mechanism?

Linear search
Binary search

Hash coded search(ans)


None of these

Sorting is not possible by using?

Insertion
Deletion(ans)
Selection
Exchange

Stack is useful to implement

Radix search
Breadth first search
Recursion(ans)
None of these

Tanuj writes the code for a function that takes an input n a nd calcutes the sum of
first n natural numbers.
Function sum(n)
{
If(??)
Return 1
Else
Return(n+sum(n-1))
End
}
N equals 1(ans)

N equals 2
n>=1
n>1

What is implied by the argument of a function?

Variables are passed to it when it is called(ans)


The value it returns on execution
The execution code inside it
Its return type

Shashi writes a program in c++ and passes it on to Pankaj. He does some


indentation in some lines of the code.What will this lead to?

Faster execution
Lower memory requirement
Correction of errors
Better readability(ans)

What is the term given to the variable whose scope is beyond all scopes? Ie. It
can be accessed by all scopes.

Universal variable
Global variable(ans)
External variable
Auto variable
Both 2 and 3

There are 2 loops which are nested. This implies?


2 loops one another
Two loops one inside the other(ans)

One loop with 2 different iteration counts


2 loops with same iteration count
The algorithm design technique used in quick sort algorithm is:

Dynamic programming
Back tracking
Divide and conquer(ans)
Greedy search

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

Address of the next node in sequence(ans)


Its own address
Address of last node
Address of first node

Yashi wants to implement priority queues using arrays.What is the minimum


number of arrays that she should use to serve the purpose?

1
2(ans)
3
4

A variable cant be used

Before declaring(ans)
After declaring
In the function it is declared in
Can always be used

For solvinfg a problem,which of these is the first step in developing a working


program for it?

Writing a program in the programming language


Writing step by step algorithm(ans)
Compiling libraries required
Code debugging

What will be the output of this pseudocode?


Integer a =456, b,c,d=10
B=a/d
C=a-b
Print c
(note:A pseudocode is used. Asuume that when two data types are processed
through an operator, the answer maintains the same datatype as the input data
types. Assume that all data types have enough range to accommodate any
number. If two different data types are operated on, the result assumes more
expensive data type.)

410
410.4
411.4
411(ans)

How can a call to an overloaded function be ambiguous?

By misspelling the name


There may be 2 functions with same name
There may be 2 or more functions with equally appropriate signatures(ans)
None of these

Which of these describe a tree?


An unconnected graph
Connected graph
Connected, acyclic graph(ans)
Complete graph

While calculating the time complexity of an algorithm, the designer concerns


himself / herself primarily with the run time and not the compile time.how?

Run time is always more than compile time


Compile time is always> run time
Compile time is a function of run time
A program needs to be compiled once but can run several times(ans)

A derived class may inherit from the base class which of the following?(consider
assumptions as c++)

Data members
Member functions
Constructors and destructors
Both data members and member functions(ans)

Tanuj writes the code for the function that takes as input n and calculate the sum
of first n natural numbers
Function sum(n)
{
if(??)
return 1
else
return(n+sum(n-1))
end
}
Fill in?? in the code

n equals 1(ans)
n equals 2
n>=1
n>1

shrishti writes the code for a function that computes the factorial of the inputted
number n.
function factorial(n)
{
if(n equal1)
return1
else
-MISSING STATEMENTEnd
}
Fill in the missing statement

Return factorial(n-1)
Return n*factorial(n)
Return n*(n-1)
Return n*factorial(n-1)(ans)

Shuti is making a questionnaire of True-false questions.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?

integer
boolean(ans)
float
character

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 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 a data structure to keep track of
the inventory.What data-structure should she use?

Queue
Stack(ans)
Array
Graph

Assume the following precedence (high to low).Operators in the same row have
the same precedence:
(.)
*/
+AND
OR
For the operators with equal precedence, the precedence is from left to right in
expression.

Integer a=40,b=35,c=20,d=10
Comment about the output of the following two statements:
Print a*b/c-d
Print a*b/(c-d)

Differ by 80(ans)
Same
Differ by 50
Differ by 160

A function contained within a class is called..?

A member function(ans)
An operator
A class function
A method

Which of the following accessibility modes can be the specifier of a top level
class?
1.private
2.protected
3.public
4.No modifier

Only 3(ans)
Only 4
Both 1 and 3
Both 2 and 3
Both 3 and 4

While calculating time complexity of an algorithm, the designer concerns


himself/herself primarily with the run time and not the compile time. Why?

Run time is always more than compile time


Compile time is always more than run time
Compile time is a function of run time
A program needs to be compiled once but can de run several times.(ans)

Shahaana has a 10,000 line code. She is trying to debug it.She knows there is a
logical error in the first 25 lines of the code.which of the following options will
be an efficient way of debugging?

Compile the whole code and step into it line by line


Use an interpreter on the first 25 lines (ans)
Compile the whole code and run it
None of these

Tanuj writes the code for a function that takes as input n and calculates the sum
of first n natural numbers.
Function sum(n0
{

If(??)
return 1
else
return (n+sum(n-1))
end
}
Fill ?? in the code

n equals 1 (ans)
n equals 2
n>=1
n>1

A full binary tree with n non-leaf nodes contains


(log n) nodes
n+1 nodes
2n+1 nodes (ans)
2n nodes
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?

Linear search
Binary search
Hash coded search (ans)
None of these

A variable cannot be used..


Before it is declared (ans)
After it is declared
In the function it is declared in

Can always be used


A linear list of elements in which deletion can be done from one end(front) and
insertion can take place at the other end (rear) is known as

Queue (ans)
Stack
Tree
Branch

A complete binary tree with 5 level has how many nodes?(Root is level 1)

15
25
63
31 (ans)

While calculating time complexity of an algorithm, the designer concerns hims


eitherself primarily with the run time and not the compile time.Why?

Run time is always more than compile time.


Compile time is always more than run time.
Compile time is a function of run time.
A program needs to be compiled once but can de run several times. (ans)

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?
Code B is better because variable names are shorter
Code A is better because the variable names are understandable and nonconfusing(ans)

Code A will run correctly, while code B will give an error


Code B will run correctly , while code A will give an error
Pankaj and Mythili were both asked to write the code to evaluate the following
expression:
a-b+c/(a-b)*(a-b)^z
Pankaj writes the following code statements(code A):
Print(a-b)+c/(a-b)*(a-b)
Mythili writes the following code statements(code B):
D=(a-b)
Print d+c/d+d*d
If the time taken to load a value in a variable, for addition,multiplication or
division between two operands is same, which of the following is true?

Code A uses lesser memory and is slower than code B (ans)


Code A uses lesser memory and is faster than code B
Code A uses more memory and is faster than code B
Code A uses more memory and is slower than code B

For solving a problem, which of these is the first step in developing a working
program for it?

Writing the program in the programming language .


Writing a step-by-step algorithm to solve the problem.(ans)
Compiling the libraries required.
Code debugging.

Which of the following data types does not belong to the category of abstract
data types?
Hashtable
Set
Object (ans)
Soting is not possible by using which of the following methods?

Insertion
Selection
Exchange
Deletion (ans)

The algorithm design technique used in the quick sort algorithm is

Dynamic programming
Back tracking
Divide and conquer(ans)
Greedy search

Assume the following precedence (high to low). Operators in the same row have
the same precedence.
(.)
*/
+AND
OR
The precedence is from 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)

The output differ by 80.(ans)


The output are the same.
The ouputs differ by 50.
The output differ by 160.

A programmer mistakenly writes gor instead of the keywordfor used in


loops, while writing a program in C++.What iwill this result in?

The code would not compile.(ans)


The code would give an error while execution.
The code may work for some inputs and not for the others.
The code would not create any problem.

A programmer writes a sorting algorithm that takes different amount of time to


sort two different lists of equal size.what is the the possible difference between
the two lists?
All numbers in one list are more than 100 while in the other are less than 100.
The ordering of the numbers with respect to the magnitude in the two lists has
different properties.(ans)
One list has all negative numbers while the other has all positive numbers.
One list contains 0 as an element while other does not.
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?
Class;Animal: objects:dog,lion and zebra: datamembers: herbivorous,
color and nocturnal (ans)
Class: Animal: objects:herbivorous,color and nocturnal;
datamember:dog,lion and zebra
Classes: dog,lion and zebra: objects:
Animals:datamembers:herbivorous,color and nocturnal
None of these
A stack is implemented as a linear array A[0N-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
{
Printunderflow
Which of the following should substitute the conditionX?

top<N-1
top<N
top>N
top >=0(ans)

A sort, which uses the binary tree concept such that any number in the tree is
larger than all the numbers in the subtree below it, is called

Selection sort
Insertion sort
Heap sort( ans)
Quick sort

In which area of class are data and function directly accessible outside the class?

Public(ans)
Private
Protected
None of these

Which of the function options refers to the data-hiding in object oriented


programming?
A class does not have function as private members.
A class has both data and functions on the data in the class.

Data in private and protected area of a class is not directly accessible and
can only be accessed through member functions in the public area of the
class.(ans)
A single class can have many objects.

Which of the of the following is the lowest level format to which the
computer converts a program in a higher language before execution?

English code
Machine code (ans)
Assembly language
System language

A sorting algorithm traverses through a list comparing adjacent element and


switching them under certain conditions. What is this sorting algorithm called?

Insertion sort
Heap sort
Quick sort
Bubble sort(ans)

A programmer writes a sorting algorithm that takes different amount of time to


sort two different lists of equal size .what is the possible difference between
the two lists?
All numbers in one lists are more than 100 while in the other are less than
100
The ordering of numbers with respect to the magnitude in the two lists has
different properties(ans)
One list has all negative numbers while the other has all positive numbers.
One list contains 0 as an element while the other does not
Integer n,I,j
Input n

For i=0 to n increment 1


{
Print end-of-line//takes the cursor to the next line
For j=0 to I increment 1
{
If(i-j equals 1)
Print1
Else
Print10
}
}
Madumita writes the given pseudo code to print a pattern on screen.
What is the pattern that this code will print on screen if the value of n is 4?

1
1
1
1

101
101
010
010

10101(ans)
10101 1010101
10101
10101 1010101

Afzal writes a piece of code, where a set of three lies occur around 10 times in
different parts of the program.what programming concept can he use to shorten
his program code length?

Use for loops


Use functions(ans)
Use arrays
Use classes

Consider the given condition in regards to binary search performed on an array


named MyArraY

1.Beg>End
2.Beg<=End
3.MyArray[mid}!=item_to_be_searched
Which of the given conditions forms the termination condition of an iterative
binary search function when the variables Beg.End and mid have their usual
meanings?

Only 1(ans)
Only2
Only 3
Both 2and 3

Which of the following refers to data hiding in object-oriented programming?


A class does not have functions as private members.
A class has both data and functions in the data in the class.
Data in the private and protected area of a class is not directly accessible
and can only be accessed through member functions in the public area of
class(ans)
A single class can have many objects.
Which of the following can be inherited by a derived class from a base class?
Data members
Member functions
Constructors and destructors
Data members and member functions(ans)
The function given below computes the factorial of the number nentered by a
user what should be the MISSING STATEMENT in order to make the code
work property?
Function factorial(n)
{

If(n equals 1)
Return 1
Else
Missing statement
End
}
Return factorial(n-1)
Return n*factorial(n)
Return n*(n-1)
Return n*factorial(n-1)(ans)
Assume the following precedence(high to low).operators in the same row have
the same precedence.
(.)
*/
+ AND
OR
The precedence is from left to right for the operators with equal precedence.
What will be the output of the following code statements?
Integer a=50, b=25,c=5
Print a*b/c/c
120
125
255(ans)

250
Preeti writes a program in a low level language,now she wants to translate it into
a higher language without rewriting the program.what another she must use for
this purpose?

Compilier(ans)
Decompiler
Interpreter
Executer
Cross compilier

In a linearlist of elements,a deletion can be made from one end(front)and an


insertioncan be made at the other end (rear).what is this linear list known as?

Queue(ans)
Stact
Tree
Branch

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?

Linear search
Binary search
Hash coded search(ans)
None of the above
What is the first step fordeveloping a working program to solve a problem?

To write the program in the programming language


To write a step-by-step algorithm to solve the problem(ans)
To compile the required libraries
To debug the code
How many nodes does a complete binary tree with 5 levels have,if the root is
considered to be at level1?

15
26
63
31(ans)

Tow programmers independently write a program to find the mass of one mole
of water ,that include sthe masses of hydrogen and oxygen
The first programmer defines the variables as:
Integer hydrogen,oxygen,water//code A
The second programmer defines three quantities as :
Integer a, b, c //code B
Which of the two is a better programming practice and why?
Code B is better because4 variable names are shorter
Code A is better because the variable names are understandable and nonconfusing(ans)
codeA would non correctly while code B would give an error
codeB would run correctly while code A would give an error
Raj has a list of n numbers each of a fixed size*he sorts them using radix sort
technique. Which of the following options gives the complexity of this
operation?

O(n-k)
O(nk)(ans)
O(k log n)
K o(log n)

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

Run time is always more than the compile time


Compile time is always more than the run time
Compile time is a function of run time(ans)
A program needs to be compiled once but can be run several times.

In which of the following methods is sorting not possible?

Insertion
Selection
Exchange
Deletion(ans)

Which of the following algorithm design techniques is used in the quick sort
algorithm?

Dynamic programming
Back tracking
Divide and conquer(ans)
Greedy search

Which of the following statements is true about a breadth first search?


Beginning from a node, all the adjacent nodes are traversed first(ans)
Beginning from a node,each adjacent node is fully explored before
traversing the next adjacent node
Beginning from a node,the nodes are traversed in cyclic order
None of the above
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 theinput.Also all data types have
enough range to accommodateanynumber.if two different datatypes are operated
upon,the result assumes the data type that is more expressive.)
Integer a=456,b,c,d=10
B=a/d
C=a-c
Print c

410

410.4
411.4
411(ans)
Function display(string mystr) //statemtnt 1
{
PrintHello My name is
Print Mystr //statement 2
}
Function main()

//statement3

{
String str=mr.beans
Integer num=display(str) //statement 4
}
Consider the given code to print a name on the screen.which statement will
generate an error?

Statement 1
Statement 2
Statement 3
Statement 4(ans)

This code will run without any error


The function given below takes a number n as the input and calculate the sum
of firstn 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}
n equals 1(ans)
nequals 2
n>=1
n>1
integer a=40,b=35,c=20,d=10
comment about the output of the following two statements:
print a*b/c-d
printa*b/(c-d)
assume the following precendence(high to low) operators in the same row have
the same precedences:
()
*/
+AND
OR
For operators with equal precedence the precedence is fromleft to right in
expression.

Differ by 80(ans)
Same
Differ by 50
Differ by 160

Sorting is not possible by using which of the following methods?

Insertion
Selection
Exchange
Deletion(ans)

Which of the following statements is true about the logical view of a database?
It is also known as physical view and there can be one or more logical
views of a database
It is also known as physical view and ter is only one logical view of a
database
It is also known as conceptual view and there can be one or more logical
views of a database
It is also known as conceptual view and there is only one logical view of a
database

Srujan writes a sorting algorithm takes different amount of time to sort two
different lists of equal size.what is the possible difference between the two lists?
All numbers in one list are more than 100.while in the other are less than
100.
The ordering of numbers wit respect to magnitude in the two list has
different properties.(ans)
One list has all negative numbers,while the other has all positive numbers.
One list contains 0 as an element,while the other does not.

Stack is useful for implementing

Radix search
Breadth first search
Recursion(ans)
None of these

Mary is making database of animals in a zoo and their properties. The poosible
animals are dog,lion and zebra.each one has a attributes in herbivorous,colour
and is nocturnal.she uses the object oriented programming paradigm for this.
How will she conceptualize the system?
Class: animal; objects:dog,lion,zebra; data members:herbivorous,colour,
nocturnal(ans)
Class: animal; objects:herbivorous,colour,nocturnal; data
members:dog,lion,zebra
Class: dog,lion,zebra; objects:animal; data members:herbivorous,colour,
nocturnal
None of these

Which of the following statements is/are true related to the kernel?


1. A kernel connects the application software to the hardware of a computer.
2. Monolithic kernel and Micro kernel are the types of a kernel.
3. The kernel has full access to the systems memory.

Only 1
Only 2
Both 1 & 2
Both 2 & 3
All-1,2,3(ans)

Stuti is making a questionaire of true-false questions.she wants to define a datatype which stores the response of the candidate for the question.what is the
most-suited data type for this purpose?
Integer
Boolean(ans)
Float

Character

What is space complexity of a program?

Amount of hard-disk space required to store the program


Amount of hard-disk space required to compile the program
Amount of memory required by the program to run(ans)
Amount of memory required for the program to compile

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?
Code b is better because variable names are shorter
Code a is better because the variable names are understandable and nonconfusing(ans)
Code a will run correctly,while code b will give an error
Code b will run correctly,while code a will give an error

How can a call to an overloaded function be ambiguous?


By misspelling the name
There might be two or more functions with the same name
There might be two or more functions with equally appropriate
signature(ans)
None of these

Consider the following psuedo-code


Class brush
{
Private:
Integer size,colorcode
Function getdata(){}//statement 1
Public:
Integer name//statement 2
Function putdata(){}
}
Function main
{
Brush b1,b2
Print b1.name//statement 3
B2.getdata()//statement4
}
Deleting which line will correct the error in the code?

Statement 1
Statement 2
Statement 3
Statement 4(ans)

In an implementation of a linked list,each node contains data and address.which


of the following can the address field possibly contain?

Address of the next node in sequence(ans)


Its own address
Address of the last node
Address of the first node

Passage:
Class rocket
{
Private:
Integer height,weight
Public://statement 1
Function input(int a,int b)
{
Height =a;
Weight =b;
}
}
Function main()
{
Rocket1,rocket2
}
Refer the psuedocode 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.what can be inferred from this code?

rocket is a class with rocket1 and rocket2 as its objects, with


height and weight as its attributes(ans)
rocket is a class with rocket1 and rocket2 as its objects, with
height and weight as its objects
rocket is a class with rocket1,rocket2,height and weight as its
attributes
rocket is a class with rocket1,rocket2,height and weight as its
objects

The program to print the larger of the two numbers entered by a user is given
below. which of the following should be substituted in place of ?? in statement
1 of the code to get the desired o/p?
Int number 1, number 2
Input number1,number2
If(??)//statement1
Print number1
Else
Print number2
End if

Number1>number2(ans)
Number2>number1
Number2=number1
Number1<=number

Which of the following statements is TRUE about variables?


A variable cannot be used before it is declared(ans)
A variable cannot be used after it is declared
A variable cannot be used in the function it is declared in

A variable can always be used

Each node in a doubly linked list contains the following parts except which one
of the following?

Header(ans)
Address of preceding element
Address of succeeding element
Information of the code

In which of the following areas of a class are data and functions directly
accessible outside the class?

Public(ans)
Private
Protected
None of the above

Which of the following refers to data hiding in object-oriented programming?


A class does not have functions are private members
A class has both data and functions in the data in the class
Data in the private and protected area of a class is not directly accessible
and can only be accessed through member functions in the public area of
the class.(ans)
A single class can have amny objects.

The functions given below computes the factorial of the number n entered by
a user . what should be the MISSING STATEMENT in order to make the code
work properly?
Function factorial(n)

{
If(n=1)
Return 1
Else
--MISSING STATEMENT
End
}

Return factorial(n-1)
Return n*factorial(n)
Return n*(n-1)
Return n*factorial(n-1)(ans)

___________is the compile time binding whereas __________ is run time


binding of functions.

Function overriding , function overloading


Abstraction , encapsulation
Function overloading , function overriding(ans)
Varies from program

Function modify(a,b)
{
Integer c,d=2
C=a*d+b
Return c
}
Function calculate()

{
Integer a=5,b=20,c
Integer d=10
C=modify(a,b);
C=c+d
Print c
}

Consider the code given in the passage.assume that a&b are passed by value.
What will the o/p of the program be when the function calculate() is executed?

80
40(ans)
32
72

A football seller stores all the footballs in a large container that Is closed from
the bottom. The footballs are stacked on top of each other in the box. The new
supply of balls is put in the box from the top. When a customer buys a football,
the one at the top of the stack is given to the customer. Each football has a code.
The seller wants to store the codes of the footballs in a data structure to keep
track of the inventory. Which data structure should be used for this purpose?

Queue
Stack(ans)
Array
Graph

While calculating time complexity of an algorithm,the designer concerns


himself/herself primarily with the runtime and not the compile time.why?

Run time is always more than compile time


Compile time is always more than run time
Compile time is a function of run time
A program needs to be compiled once but can be run several times(ans)

Function sum(n)
{
If(??)
Return 1
Else
Return{n+sum(n-1)}
End
}
Fill in ?? in the code

n=1(ans)
n=2
n>=1
n>1

A full binary tree with n non-leaf nodes contains

(log n) nodes
n+1 nodes
2n+1 nodes(ans)
2n nodes

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?

The code will not compile(ans)


The code will give an error while in execution
The code may work for some inputs and not for others
It will create no problems

A sorting algorithm traverses through a list, comparing adjacent elements and


switching them under certain conditions.what is this sorting algorithm called?

Insertion sort
Heap sort
Quick sort
Bubble sort(ans)

There are 2 loops which are nested. This implies which one of the following?

Two loops, one after another


Two loops,one inside the other(ans)
One loop with two different iteration counts
Two loops with the same iteration counts

What is implied by the argument of a function?

The variables passed to it when it is called(ans)


The value it returns on execution
The execution code inside it
Its return type

In an implement of a linked list,each node contains data and address.which of


the following could theaddress field possibly contain?

Address of next node in sequence(ans)


Its own address
Address of last node
Address of first node

Stuti is making a questionnaire of true-false questions.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?

Integer
Boolean(ans)
Float
Character

Group a

Group b

A.distance
vector interior
routing
protocol

1.open shortest
path first(OSPF)

B.distance
vector
exteriorrouting
protocol

2.enhanced
interior gateway
routing
protocol(EIGRP)

C.link state
interior
routing
protocol

3.routing
information
protocol(RIP)

D.hybrid
interior

4.border
gateway

routing
protocol

protocol(BGP)

Match the given routing strategies in group A with their example in group B
A-1,B-2,C-3,D-1
A-1,B-4,C-2,D-3
A-3,B-4,C-1,D-2
A-4,B-3,C-1,D-2
Zenab and shasi independently write a program to find the mass of one mole of
water,which includes mass of hydrogen and oxygen.zenab defines the variables
into per hydrogen ,oxygen,water// code A
While shashi defines the three quantities as:
Integer a,b,c//code B
Which is the better programming practiceand why?
Code B is the better because variable names are shorter
Code A is better because the variable names are understandable and non
confusing(ans)
Code Awil rin correctly,while code B wil give an error
Code Bwil rin correctly,while code A wil give an error
Ravi and Rupali are asked to write a program to sum the rows of a 2*2 matrices
stored in the array A.
Ravi writes the following code(codeA):
For n=0 to 1
Sumrow1[n]=A[n][1]+a[n][2]
End
Rupali writes the following code (code B):

sumRow1[0]=A[0][1]+A[0][2]
sumRow1[1]=A[1][1]+A[1][2]
comment upon these codes (assumeno loop unrolling done by complier):

code A wil execute faster than code B


code B wil execute faster than code A(ans)
code A is logically incorrect
code B is logically incorrect

In an implementation of a linked list,each node contains data and addres.which


of the following could the addres field possiblycontain?

Addres of next node in sequence(ans)


Its own addres
Addres of last node
Addres of first node

Consider the folloing pseudocode


Class brush
{
Private:
Integer size,colorcode
Function getdata(){.}
}
Function name main
{
Brush b1,b2
Print b1.name//statement 3
B2.getdata()//statement 4
}

Choose the correct answer.A pseudocode which is similar to that of c++


And self explantory.an accessible member functions or data member for
anobjectname .datamembername respectively.
Statement 1
Statement 2
Statement 3
Statement 4
A stack is implemented as a linear array A[0n-1].Noor writes the following
functions fo popping an elemented the stack
function POP(top N)
{
if(X)
{
top=top-1
}
else
{
Printunderflow
}
return top
}
Fil in the condition X
Choose the correct answer
top<N-1(ans)

top
top>1
top>=0
Smriti awnts to make a program to print the sum of a square of the first %
wholenumbers(0..4).she writes the following 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
Is her program correct?if not,which statement wil you modify to correct it?
Choose the correct ans:

No error,the program is correct


Statement 1
Statement 4(ans)
Statement 6

Afzal writes a piece of code,where a set of three lines occur around 10 times in
different parts of the program.what programming conc ept can he use to shorten
his [program code length?
Choose the correct ans:

Use for loops


Use functions(ans)
Use arrays
Use classes

How many nodes does a complete binary tree with 5 levels have,if the root is
considere to be at level 1?

15
25
63
31(ans)

Choose the correct ans:


In a linear list of elements,a detection can be made from one end(front)and an
insertion can be made at the other end(rear).what is this linear list known as?

Queue(ans)
Stack
Tree
Branch

A programmer mistakenly writes gor instead of the keyword for used in


loops.while wriring a program in c++.what wil this result in?

The code would not compile(ans)


The code would give an error while execution
The code may work for some inputs and not for the others
The code would not create any problem

What is the first step for developing a working program to solve a problem?
To write the program in the programming language
To write a step-by-step alogrithm to solve the problem(ans)
To compile the required libraries
To debug the code
Consider the given list of sorting algorithms1.selection sort
2.radix sort
3.shell sort

4.heap sort
Which of the above mentioned algorithms uses the selection method for bringing
out the sorting?

Only 1(ans)
Only 3
Both 1 ana 4
Both 2 and 3
Both 2 and 4

Two programmers independently write a program to find the mass of one mole
of water ,that includes the masses of hydrogen and oxygen
The first programmer defines the variables as:
Integer a,b,c //code A
The second programmer defines three quantities as;
Integer a,b,c //code B
Which of the two is a better programming practise and why?
Code Bis better than because variable names are shorter
Code Ais better because the variable names are understandable and non
confusing(ans)
Code A would run correctly while code B would give an error
Code B would run correctly while code A would give an error
In which of the following methods is sorting NOT possilble?

Insertion
Selection
Exchange
Deletion(ans)

Every element of a data structure has an address and a key associated with it.A
search mechanism deals with 2 ior more values assigned to the same address by
using the key.what is the search mechanism?

Linear search
Binary search
Hash coded search(ans)
None of the above

What is implied by the argument of a function?

The variables passed to the function when it is called(ans)


The value that the function returns on execution
The execution code inside the function
Return type of the function

Function MyFunc1(integer n)
{
return n*2
}
Function MyFunc2(integer n0
{
Printthe values is n
}
A pseudo code is used which is self explanatory.
Which of the given 2 functions can be categorized as procedues?
MyFunc 1
MyFunc2
Both MyFunc1 and MyFunc2
A function cannot be a procedure

In which of the following cases .doubly linked list are preferred over singly
linked list?
Searching an item in an unsorted list
Traversing a list
Deleting a node whose location is given (ans)
Interchanging 1 nodes
The program to print the larger of the 2 numbers entered by a user is given
below.which of the following should be substituted in place of ??
Int number1,number2
Input number1,number2
If(//)//statement 1
Print number 1
Else
Print number2
Endif

Number1>number2(ans)
Number 2>number1
Number2 equals number 1
Number1<=number2

Which of the following refers to data hiding in object oriented programming?


A class does not have functions as private members
A class has both data and functions in the data in the class
Data in the private and protected area of a class is not directly accessilble
and can only be accessed through class(ans)
A single class can have many objects
What wil happen if some indentions are made in some statements of a code
written in c++?

Faster execution of the code


Lower memory requirement for the code
Correction of errors in the code
Better readability of the code(ans)

In which of the following situations can a constructor be invoked?

When an object is created(ans)


When an object is assigned the value 0
Only at the end of the code
When the scope of the object is over

A programmer writes a 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?

For loops
Functions(ans)
Arrays
Classes

The function given below takes number n as the input and calculate 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
}

n equals 1(ans)
n equals 2
n>= 1
n>1

which of the following options gives the lower bound on running time for an
algorithm?
Best case complexity of the algorithm
Average case complexity of the algorithm
Worst case complexity of the algorithm
Number of iterations taking place in the algorithm
Assume the following precedence (high to low).operations in the same row have
the same precedence.
(.)
*

+ AND
OR
The precedence is from 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
statement given below?
Integer a=40,b=35,c=20,d=10
print a*b/c-d
print a*b/(c-d)

the outputs differ by 80(ans)


the outputs are same
the outputs differ by 50
the output differ by 160

A sorting mechanism uses the binary tree concept such that any number in the
tree is larger than all number in the subtree below it . what is the method called?

Selection sort
Insertion sort
Heap sort(ans)
Quick sort

The following operations are performed on an empty stack 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.)

56

1 5(ans)
56
15

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 the search mechanism?

Linear search
Binary search
Hash coded search(ans)
None of the above

A programmer mistakenly writes gor instead of the key word for used in
loops, while writing a program in c++ . what will this result in?

The code would not compile.(ans)


The code would give an error while execution.
The code work for some inputs and not for the others.
The code would not create any problem.

Tricha needs to store a list of binary data. Which of the following data types
should she use?
Integer
Float
Character

Boolea(ans)

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

Run time is always more than the compile time


Compile time is always more than run time
Compile time is a function of run time.
A program needs to be compiled once but can berun several times.(ans)

Which of the following is the lowest level format to which the computer
converts a program in a higher language before exacution?

English code
Machine code(ans)
Assembly language
System language

What is the name given to the function which has no memory or i/o side effects
>

Pure function(ans)
Subroutine
Procedure
Method

In an implementation of alinked list,each node contains data and address. Which


of the following can the address field possibly contain?

address of the next node in sequence(ans)


Its own address
Address of the last node
Address of the first node

Find out the index of an empty hash table where a key with value 25 needs to be
inserted using quadratic probing with c1=1,c2=9. The size of table is 5 and
primary hash function used is(k mod m)where k=key,m=size of hash table.

0(ans)
1
15
Data insufficient

What will happen if some indentations arte made in some statements of a code
written in c++?
Faster execution of the code
Lower memory requirement for the code
Corrections of errors in the code
Better readability of the code(ans)

Which of the following accessibility modes can be the specifier of a top level
class?
1.private
2.protected
3.public
4.no modifier

Only 3(ans)
Only 4
Both 1and 3
Both 2 and 3
Both 3 and 4

A programmer prepares a questionnaire withtrue or false types of question . he


wants to define a data type that stores the responses of the candidates for the
questions. Which of the following is the most type for this purpose?

Integer
Boolean(ans)
Float
character

function modify(a,b)
{
integer c,d-2
C=a*d+b
return c
}
Function calculate()
{
integer a=5,b=20,c;
integer d=10;
c=modify(a,b)
c=c+d;
print c
}

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 calculate() is
executed?

80
40(ans)
32
72

How many nodes does a complete binary tree with levels have, if the root is
considered to be at level 1?

15
25
63
31(ans)

How many nodes does a full binary tree with n non-leaf nodes contais?

Log n
n+1
2n+1(ans)
2n

A programmer mistakenly writes for used in loops, while writing a program


in c++.what will this result in?

The code would not compile.(ans)


The code would give an error while execution.
The code work for some inputs and not for the others.
The code would not create any problem.

Function main()
{
Automatic variable var
Print var
}
What will be the output generated when the given code is executed?

0(ans)
1
Garbage value
This code will generate a compile time error

A programmer writes a sorting algorithm that takes different amount of time to


sort two different lists of equal size. What is the possible difference between the
two list

All numbers in one list are more than 100 while in the others are less than
100
The ordering of numbered with respect to the magnitude in the two lists
has different properties(ans)
One list has all negative numbers while the others has all positive numbers
One list contains 0 as an element while the others does not.

What is implied by the argument of a function?

The variable passed to the function when it is called.(ans)


The value that the function returns on execution
The execution code inside the function
Return type of the function

Function mybinarysearch(array arr , integer low , integer high , integer item)


{
if(low > high)
{
Return -1
}
Integer mid =(low+high)/2
if(arr[mid] equals item)
{
return mid
}
else if(arr[mid] > item)
{
Return// missing statement 1
}
Else
{
Return // missing statement 2
}
}
Harshul uses the given code to implement binary search recursively . find the
statement that will replace missing statement 2 in the given code such that it
works efficiently.

Mybinarysearch(arr , mid+1 , high , item)(ans)


Mybinarysearch(arr , low+1 , mid-1 , item)
Mybinarysearch(arr , low , mid1 , item)
Mybinarysearch(arr , mid+1 , high -1, item)

What will happen if some indentations arte made in some statements of a code
written in c++?

Faster execution of the code


Lower memory requirement for the code
Corrections of errors in the code
Better readability of the code(ans)

A complete graph contains 10 nodes. What is the total number of edges

45(ans)
50
90
99

In which of the following situations can a constructer be invoked?

When an object is created(ans)


When an object is assigned the value 0
Only the end of the code
When the scope of the object is over

A programmer wants the program given below to print the largest munber out of
three numbers entered by the user.
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
Which of the following should be substituded in place of ?? in statement 1 in
the code?

Number 3> number 2


Number 3>temp(ans)
Number<temp
Number3> number1

Ritika was asked to include concrete objects in her project . which of the
following statement clearly states about the concrete objects?

All the objects created as the instance of a class(ans)


Objects created using the new key word

Variables and objects that follow the concrete ketword


Objects created under conditional statements

A queue is implemented as asingly 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 isegual is true?

It has no element(ans)
It has one element
There is an error
None of the above

A sorting algorithm through a list comparing adjacent elements and switiching


them under certain conditions . what is this called?

Insertion sort
Heap sort
Quick sort
Bubble sort(ans)

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

Hashtable
Set
Object(ans)
stack

which of the following describes a tree?

An unconnected graph
A connected graph
A connected acyclic graph(ans)
A complete graph

Two programmers independently write a program to find the mass of one mole
of water , that includes the masses of hydrogen and oxygen
The first programmer defines the variable as :
Integer hydrogen , oxygen , water //code A
The second programmer defines three quantities as:
Integer a,b,c, // code B
Which of these two is better programming practice and why?

Code B is better because variable names are shorter


code A is better because the variable names are understandable and nonconfusing.(ans)
Code A would run correctly while code B would give an error
Code AB would run correctly while code A would give an error
Pragya sells football . she has a large container to store footballs which is
closed from below . footballs are piled ane on top of the other in the box from
the top . when a customer buys a ball , she delieverd the ball at the top of the pile
top the customer . each ball has a code . she wants to store the ball codes in a
data structure to keep track of her inventory . what data structure should she use

Queue
Stack(ans)
Array
Graph

You might also like