Placement Written test paper for MNC || Computer questions and answers Part – 3

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

Ques 62 : Choose the correct answer
Pavithra is given two codes, A and B, to solve a problem, which have complexity θ(n3) and ω(n3) respectively. Her client wants to solve a problem of size k, which is sufficiently large. Which code should she deliver to the client in the present scenario?
Option 1 : Code A Option 2 : Code B Option 3 : Both codes have the same execution time, so deliver any. Option 4 : None of these

Ques 63 : Choose the correct answer
Code A has to execute 4*n2 + 64 program statements, while Code B has to execute 32*n program statements for a problem of size n. The time for executing a single program statement is same for all statements. Rajesh was given a problem with a certain size k and he delivered Code A. What could be the possible value of k?
Option 1 : 1000 Option 2 : 5 Option 3 : 10 Option 4 : 3

Ques 64 : Choose the correct answer
Saumya writes a code which has a function which calls itself. Which programming concept is Saumya using?
Option 1 : This is bad programming practice and should not be done. Option 2 : Recursion Option 3 : Decision Making Option 4 : Overloading

Ques 65 : Choose the correct answer
Shrishti writes the code for a function that computes the factorial of the inputted number n.

function factorial(n)
{
if(n equals 1)
return 1
else
— MISSING STATEMENT —
end
}

Fill in the missing statement.

Option 1 : return factorial(n-1) Option 2 : return n*factorial(n) Option 3 : return n*(n-1) Option 4 : return n*factorial(n-1)

Ques 66 : Choose the correct answer
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.

Option 1 : n equals 1 Option 2 : n equals 2 Option 3 : n >= 1 Option 4 : n > 1

Ques 67 : Choose the correct answer
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 statement, sum(30). How many times will the function sum be called to compute this sum.

Option 1 : 1 Option 2 : 30 Option 3 : 15 Option 4 : 16

Ques 68 : Choose the correct answer
Consider the following function

function calculate( n )
{
if(n equals 5)
return 5
else
return (n + calculate(n-5))
end
}

Shishir calls the function by the statement, calculate(20). What value will the function return?

Option 1 : 50 Option 2 : 200 Option 3 : 35 Option 4 : 20

Ques 69 : Choose the correct answer
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?
Option 1 : The code will not compile. Option 2 : The code will give an error while in execution Option 3 : The code may work for some inputs and not for others. Option 4 : It will create no problems.

Ques 70 : Choose the correct answer
What does a compiler do?
Option 1 : Converts code from a high level language to a low level language Option 2 : Necessarily converts the code into assembly language Option 3 : Converts code from a low level language to a high level language Option 4 : Necessarily converts the code into machine language

Ques 71 : Choose the correct answer
A program is compiled by Tarun on his machine. Whether it will run on a different computer will depend upon:
Option 1 : Operating system on the computer Option 2 : Hardware configuration of the computer Option 3 : Both operating system and hardware configuration Option 4 : The language of the program

Ques 72 : Choose the correct answer
Sakshi writes a code in a high-level programming language on a Pentium-III machine, which she wants to execute on a Motorola chip. What of the following will she run on the code?
Option 1 : An interpreter Option 2 : A compiler Option 3 : A cross-compiler Option 4 : Linker

Ques 73 : Choose the correct answer
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 will be an efficient way of debugging:
Option 1 : Compile the whole code and step into it line by line Option 2 : Use an interpreter on the first 25 lines. Option 3 : Compile the whole code and run it Option 4 : None of these

Ques 74 : Choose the correct answer
Farhan writes a code to find the factorial of an inputted number. His code gives correct answer for some inputs and incorrect answers for others. What kind of error does his program have?
Option 1 : Syntactical error Option 2 : Run-time Error Option 3 : Logical Error Option 4 : None of these

Ques 75 : Choose the correct answer
Reshama is debugging a piece of code which takes several iterations of modifying and executing code, while Mohammad has to deliver a product to the customer, which the customer will run multiple times. Reshama wants her debug cycle to take minimum possible time, while Mohammad wants that his products run time is minimum. What tools should Reshama and Mohammad respectively use on their code?
Option 1 : Compiler, Interpreter Option 2 : Interpreter, Compiler Option 3 : Compiler, Compiler Option 4 : Interpreter, Interpreter

Ques 76 : Choose the correct answer
Gautam writes a program to run on a Motorola processor on his Pentium computer. He wants to see how the program will execute on the Motorola processor using his Pentium machine. What tool will he use?
Option 1 : Compiler Option 2 : Interpreter Option 3 : Assembler Option 4 : Simulator

Ques 77 : Choose the correct answer
Consider the following code:

function modify(y,z)
{
y = y + 1;
z = z + 1;
return y – z
}

function calculate( )
{
integer a = 5, b = 10, c

c = modify(a, b);
print a
print space
print c
}

Assume that a and b were passed by value. What will be the output on executing function calculate( )?

Option 1 : 11 -5 Option 2 : 10 -5 Option 3 : 6 -5 Option 4 : 5 -5

Ques 78 : Choose the correct answer
Consider the following code:

function modify(b,a)
{
return a – b
}

function calculate( )
{
integer a = 5, b = 12, c

c = modify(a, b);
print c
}

Assume that a and b were passed by reference. What will be the output of the program on executing function calculate( ) ?

Option 1 : 7 Option 2 : -7 Option 3 : Error Option 4 : 8

Ques 79 : Choose the correct answer
Consider the following code:

function modify(y,z)
{
y = y + 1
z = z + 1
return y – z
}

function calculate( )
{
integer a = 12, b = 20, c

c = modify(a, b);
print a
print space
print c
}

Assume that a and b were passed by reference. What will be the output of the function calculate( ) ?

Option 1 : 12 -8 Option 2 : 13 -8 Option 3 : 12 8 Option 4 : 13 8

Ques 80 : Choose the correct answer
Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the program. What programming concept can he use to shorten his program code length?
Option 1 : Use for loops Option 2 : Use functions Option 3 : Use arrays Option 4 : Use classes

Ques 81 : Choose the correct answer
Geetika writes a piece of code, where a set of eight lines occur around 10 times in different parts of the program (Code A). She passes on the code to Deva. Deva puts the set of eight lines in a function definition and calls them at the 10 points in the program (Code B). Which code will run faster using an interpreter?
Option 1 : Code A Option 2 : Code B Option 3 : Code A and Code B will run with the same speed Option 4 : None of these

Ques 82 : Choose the correct answer
Consider the following code:

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
}

Assume that a and b were passed by value. What will be the output of the function calculate( ) ?

Option 1 : 80 Option 2 : 40 Option 3 : 32 Option 4 : 72

Ques 83 : Choose the correct answer
Consider the following code:

function modify(w,u)
{
w = w + 2
u = u – 3
return (w – u)
}

function calculate( )
{
integer a = 10, b = 20, c
c = modify(a, b);
print a
print space
print b
}

Assume that a was passed by value and b was passed by reference. What will be the output of the program on executing function calculate( ) ?

Option 1 : 12 17 Option 2 : 10 17 Option 3 : 12 20 Option 4 : 10 20

Ques 84 : Choose the correct answer
Consider the following function:

function run( )
{
integer a = 0 // Statement 1
while (a < 5)
{
integer c = 0   // Statement 2
c = c + 1   // Statement 3
a = a + 1
}
print c   // Statement 4
}

At which statement in this program will the compiler detect an error?

Option 1 : Statement 1 Option 2 : Statement 2 Option 3 : Statement 3 Option 4 : Statement 4

Ques 85 : Choose the correct answer
Which one of the following is the lowest level format to which the computer converts a higher language program before execution?
Option 1 : English code Option 2 : Machine Code Option 3 : Assembly Language Option 4 : System Language

Ques 86 : Choose the correct answer
If you want to write a function that swaps the values of two variables, you must pass them by:
Option 1 : Value only Option 2 : Reference only Option 3 : Either A or B Option 4 : Neither A nor B

Ques 87 : Choose the correct answer
Consider the following code:

if (condition 1) {
if (condition 2)
{   // Statement A   }
else
if (condition 3)
{ // Statement B }
else
{ // Statement C }
else
if (condition 4)
{ // Statement D }
else
{ // Statement E}
}
Which of the following conditions will allow execution of statement C?

Option 1 : condition1 AND condition3 Option 2 : condition1 AND condition4 AND !condition2 Option 3 : NOT(condition2) AND NOT(condition3) Option 4 : condition1 AND NOT(condition2) AND NOT(condition3)

Ques 88 : Choose the correct answer
Consider the following code:

if (condition 1) {
if (condition 2)
{ // Statement A }
else
if (condition 3)
{ // Statement B}
else
{// Statement C }
else
if (condition 4)
{// Statement D}
else
{// Statement E}
}

Which of the following conditions will allow execution of statement E?

Option 1 : condition1 AND condition3 Option 2 : NOT(condition1) AND condition2 AND NOT(condition4) Option 3 : NOT(condition2) AND NOT(condition3) Option 4 : condition1 AND condition4 AND NOT(condition2) AND NOT(condition3)

Ques 89 : Choose the correct answer
Consider the following code:

if (condition 1) {
if (condition 2)
{ // Statement A }
else
if (condition 3)
{ // Statement B}
else
{// Statement C }
else
if (condition 4)
{// Statement D}
else
{// Statement E}
}

Which of the following condition will allow execution of statement A?

Option 1 : NOT(condition2) AND NOT(condition3) Option 2 : condition1 AND condition4 AND NOT(condition2) AND NOT(condition3) Option 3 : condition1 AND condition2 AND condition4 Option 4 : NOT(condition1) AND condition2 AND NOT(condition4)

Ques 90 : Choose the correct answer
What does the following function do?

function operation (int a, int b)
{
if (a < b)
{ return operation(b, a) }
else
{ return a }
}

Option 1 : Returns the max of (a,b) Option 2 : Returns the min of (a,b) Option 3 : Loops forever Option 4 : Always returns the second parameter

Leave a Reply

Your email address will not be published.

nineteen − fourteen =