Hello friends in this post we are going to discuss AMCAT Technical Multiple choice questions | AMCAT Technical MCQ with answers | AMCAT Technical Objective type questions | AMCAT Technical Most asked questions

## 1- What is the term given to the variable whose scope is beyond all the scope i.e it can be accessed by all the scope?

1 – Universal Variable2 – Global Variable3 – External Variable4 – Auto variable5 – Both 2 and 3

Answer: 5

Explanation: Global Variable is Variable that is Globally available.Scope of Global variable is throughout the program [ i.e in all functions includingmain() ]It is possible to define variables that are external to all functions,that is, variables that can be accessed by name by any function because externalvariablesare globally accessible, external variables remain in existence permanently, rather thanappearing and disappearing as functions are called and exited, they retain their valuesevenafter the functions that set them have returned.An external variable must be defined, exactly once, outside of any function; this setsasidestorage for it. The variable must also be declared in each function that wants to accessit; thisstates the type of the variable. The declaration may be an explicit extern statement ormaybe implicit from context

## 2 – 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.3 – One loop with two different iteration counts4 – Two loops with same iteration count

Answer: 2

Explanation: In nested loop, the outer loop contains the inner loop.

## 3 – Refer to the pseudo code given in the ‘passage’. The code is similar to that inC++and is self explanatory An accessible member function and a data member for anobject are accessed by the statements objectname.functionname andobjectname.datamembername , respectively.

## 1 – Identify the statement with an error.

## Class entity{Private:Integer a,bPublic:Integer cFunction entity(){a=0;b=0}Function compare (){If(a>b) return 1;return 0}}function main(){Entity blackInt value,value2=5Value=black.compare() // Statement1Black.c=value2 // Statement 2Print black.a // Statement 3}

1 – Statement 1

2 – Statement 2

3 – Statement 3

4 – None of the above

Answer: 3

Explanation :- “a” variable is private to the class entity so it cannot be accessed by main

function. If you want to access then we can use friend function and friend class.

## 4 – What does function overloading implies?

1 – Many function definitions with the same name, different arguments and differentreturn types.

2 – Many function definitions with the same name, same arguments and different returntypes.

3 – Many functions definitions with the same name and same arguments.

4 – None of the above

Answer: 1.

Explanation: Function overloading means two or more functions can have the samename buteither the number of arguments or the data type of arguments has to be different.Return type has no role because function will return a value when it is called and atcompiletime compiler will not be able to determine which function to call.

## 5 – A programmer writes the program given in the ‘Passage’ to print the followingpattern on the screen:

## 112123

## Will this program function properly? If not, which statement should be modified?

## Integer I =1 // Statement 1While(i<=3){Int j= 1// Statement 2While (j<=1) // Statement 3{Print j Print blank spaceI=j+1 // Statement 4}Print end-of-line takes the cursor to the next linei=i+1}

1 – Statement 1

2 – Statement 2

3 – Statement 3

4 – Statement 4

Answer 3

Explanation: Modify 3 statement as while(j<=i).

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

## Function modify(b,a){Return a-b}Function calculate(){Integer a=5,b=12,cC=modify(a,b)Print c}

a. 7

b. -7

c. 0

d. None

Answer- b

Explanation; 5, 12 pass to the function thus 5-12= -7

## 7 – What is the output of the program given below? Integer i=0,jWhile(i<2){j=0;While(j<=3*i){print jprint blank spacej= j+3}Print end-of-line // takes the cursor to the next lineI=i+1}

a – 00303036

b-00360369

c-03603690 3 6 9 12

Answer – a

Explanation:

a – Initial i= 0 and in while loop while(i< 2) satisfied here assigning j = 0 again while loopcondition satisfied so in first time it will print value of j=0.b – Now j = j + 3 means it will be 3 but inside loop condition fail then in next line it willprintnext line an i value will be i = i + 1; means now i will be one again it will reach at initialwhile loopcondition satisfied i value 1 and j again assigned j = 0 c – Now condition satisfied in second while loop then print 0 again j value will be 3 and itwillsatisfiedd- again second while loop then it will print 3 now j become 6 and second while loopconditionfail so in next line it will print next line and i will be 2e – Now control goes to first while loop condition fail.

## 8 – Neelam wants to share her code with a colleague, who may modify it. Thus shewants to include the date of the program creation, the author and otherinformationwith the program. What component should she use?

1 – Header files2 – Iteration3 – Comments4 – Preprocessor directive

Answer: 3

Explanation: Comments are also known as document section.

## 9 – What will happen if some indentations are made in some statements?

1 – Faster execution of the code

2 – Lower memory requirement for the code.

3 – Correction of error in the code

4 – Better readability of the code

Answer: 4

Explanation: neat and clean Programs.

## 10 – How many nodes do a full binary tree with “n” non leaf nodes contains?

1 – Log n

2 – N+1

3 – 2n+1

4 – 2n

Answer: 3

Explanation: Non leaf node i.e.; root for a full binary tree it has left child, right child so n(root+ left+ right)=3 nodes (2*1 +1) if n is 3 each left and right have 2 child each so 7 nodes =2*3+1 so answer is 2n+1 nodes

## 11 – In which of the following method is sorting not possible?

1 – Insertion

2 – Selection

3 – Exchange

4 – Deletion

Answer: 4

Explanation: Using insertion, selection, exchange we interchange the values in sortedorderbut deletion is not related to searching and sorting.

## 12 – Ravi and Rupali are asked to write a program to sum the rows of a 2X2matricesstored in the array A.Ravi writes the following code (Code A):for n = 0 to 1sumRow1[n] = A[n][1] + A[n][2]endRupali 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 (Assume no loop-unrolling done by compiler):

1 – Code A will execute faster than Code B

2 – Code B will execute faster than Code A

3 – Code A is logically incorrect.

4 – Code B is logically incorrect.

Answer: 2

Explanation: Both codes are taking 2 steps of operation, therefore same complexity.But if we consider the overhead of looping (as it takes time to increment counter) thencode b will be faster.

## 13 – A code takes the following code steps (equivalently time unit) to execute:5*n3 + 6*n2 + 1. Which of the following is not true about the time complexity of theprogram?

1 – It has a time complexity of O(n3)

2 – It has a time complexity of O(n4)

3 – It has a time complexity of O(n2)

4 – It has a time complexity of &theta(n3)

Answer: 3

Explanation: O (n3) while calculating the time complexity we take the highest order ofthefunction. e.g if expression is x^5+x^4+x^2+521 then it’s O(x^5)

## 14 – We have two programs. We know that the first has a time complexity O(n 2),while the second has a complexity &omega(n2). For sufficiently large n, which ofthefollowing cannot be true?

1 – Both codes have same complexity

2 – The first code has higher time complexity than the second

3 – The second code has lower time complexity than the first code.

4 – Both codes are the same.

Answer: 1

Explanation: Code A has O (n2) complexity which means worst case complexity whereascode B has omega (n2) which is best case complexity.

## 15 – Rajini is given an efficient code for summing two nXn matrices and puttingtheresult in a third Matrix. She is asked to find it’s time complexity. She realizes thatthe number of iterations required is more than n. What can she claim with regardto the complexity of the code?

1 – It is O(n)

2 – It is O(n2)

3 – It is &theta(n)

4 – It is &omega(n)

Answer: 2

Explanation: For nXn matrix we need two for loop so time complexity will be O (n 2).

## 16 – Surbhi is given two codes, A and B, to solve a problem, which havecomplexityO(n3) and &omega(n4) respectively. Her client wants to solve a problem of size k,which is sufficiently large. Which code will Surbhi deliver to the client, so that theexecution is faster?

1 – Code A

2 – Code B 3 – Surbhi cannot determine 4 – Both codes have the same execution time, so deliver any.

Answer: 2

Explanation: Code b as big omega is used for best execution time

17 – Vibhu is given two codes, A and B, to solve a problem, which havecomplexityO(n4) and &omega(n3) respectively. Her client wants to solve a problem of size k,which is sufficiently large. Which code will Gautam deliver to the client, so thatthe execution is faster?

1 – Code A

2 – Code B

3 – Vibhu cannot determine

4 – Both codes have the same execution time, so deliver any.

Answer: 3

Explanation: Vibhu cannot determine. Because we do not know the case of complexityforcode B

## 18 – Saumya writes a code which has a function which calls itself. Which programming concept is Saumya using?

1 – This is bad programming practice and should not be done.

2 – Recursion

3 – Decision Making

4 – Overloading

Answer: 2

Explanation: Recursion function can call itself

## 19 – Shrishti writes the code for a function that computes the factorial of the inputted number n.

## function factorial(n){if(n equals 1) return 1else– MISSING STATEMENT — end}Fill in the missing statement.

1 – return factorial(n-1)

2 – return n*factorial(n) *

*3 – return n*(n-1)

4 – return n*factorial(n-1) Op 5:

Answer: 4

Explanation: return n*fact(n-1) since its a recursive factorial(n) then there is a need tocall thefactorial(n) every time.

## 20 – 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.

1 – n equals 1

2 – n equals 2

3 – n >= 1 Op 4-n>1

Answer: 1

Explanation: e.g. n=3=3+sum(2)=3+2+sum(1)

## 21 – 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.

a – 1

b – 30

c – 15

d – 16

Answer: c

Explanation: In question they specifically told even numbers only. So in 30 numbersthere willbe 15 even numbers and 15 odd numbers so the sum function called 15 times.

## 22 – Consider the following function function calculate( n ){if(n equals 5) return 5 else return(n+calculate (-5)) end}Shishir calls the function by the statement, calculate(20). What value will the function return?

a – 50

b – 200

c – 35

d – 20

Answer: a

Explanation: Its recursive function.

calculate(20) returns (20+calc(20-5))=20+calc(15)=20+15+calc(10)=20+15+10+calc(5)=20+15+10+5=50

## 23 – 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?

1 – The code will not compile.

2 – The code will give an error while in execution

3 – The code may work for some inputs and not for others.

4 – It will create no problems.

Answer: 1

Explanation: The code will not compile and will show syntax error.

## 24 – What does a compiler do?

1 – Converts code from a high level language to a low level language

2 – Necessarily converts the code into assembly language

3 – Converts code from a low level language to a high level language

4 – Necessarily converts the code into machine language

Answer: 1

Explanation: A compiler is a program that translates the source code for anotherprogramfrom a programming language into executable code. The source code is typically in ahigh-level programming language (e. g. Pascal, C, C++, Java, Perl, C#, etc).

## 25 – A program is compiled by Tarun on his machine. Whether it will run on a different computer will depend upon:

1 – Operating system on the computer

2 – Hardware configuration of the computer

3 – Both operating system and hardware configuration

4 – The language of the program

Answer: 3

Explanation: Platform = OS + Hardware configuration so to run on different computer, ithasto provide same platform virtual machine that can provide same environment(e.g JVM incaseof java) so either of the above case we are providing platform(directly or indirectly) thelanguage of the program is even dependent upon the 2 factors 1)operating system ofthecomputer. 2) Hardware configuration (that mainly include processor) of the computer

## 26 – There is a new data-type which can take as values natural numbers between(and including) 0 and 25. How many minimum bits are required to store this data type.

a. 4

b. -5

c. 1

d. 3

Answer: b

Explanation: – 5 because 25 is represented by 10011 which is a 5-bit number.

## 27 – A data type is stored as an 6 bit signed integer. Which of the following can not be represented by this data type?

a. -12

b. 0

c. 32

d. 18

Answer: c

Explanation:-as -2^((n-1))+1 to 2^(n-1)-1so if -2^(6-1)+1 to 2^(6-1)-1then -31 to 31

## 28 – A language has 28 different letters in total. Each word in the language is composed of maximum 7 letters. You want to create a data-type to store a word of this language. You decide to store the word as an array of letters. How many bits will you assign to the data-type to be able to store all kinds of words of the language?

a – 7

b – 35

c – 28

d – 196

Answer: b

Explanation:-No. of words in the language = 28these letters are denoted in form of numbers 1-28ex– first letter = 1 (in binary form- 1)second letter = 2 (in binary form- 10) last letter = 28 (in binary form- 11100)the last letter has a total of 5 bits!!!!So, minimum memory required for a single letter is 5 bits!!!!therefore, for 7 letters it will be– 7×5=35

## 29 – A 10-bit unsigned integer has the following range:

a – 0 to 1000

b – 0 to 1024

c – 1 to 1025

d – 0 to 1023

Answer: d

Explanation: Using formula unsigned no range: 0 to 2^n-12^10-1=1023

## 30 – Rajni wants to create a data-type for the number of books in her book case. Her shelf can accommodate a maximum of 75 books. She allocates 7 bits to the datatype. Later another shelf is added to her book-case. She realizes that she can still usethesame data-type for storing the number of books in her book-case. What is the maximum possible capacity of her new added shelf?

a – 52

b – 127

c – 53

d – 75

Answer: a

Explanation:- Since max possible combination of data type is 2^7=127, Because it issingedinteger so, signed integer can store up to 0 to 127 for 7 bits . Now old self can take max75books so still she has 52 capacities left. so max possible capacity=52 i.e., 127-75=52

## 31 – A new language has 15 possible letters, 8 different kinds of punctuation marks anda blank Character. Rahul wants to create two data types, first one which could store the letters of the language and a second one which could store any character in the language. The number of bits required to store these two data-types will respectively be:

a – 3 and 4

b – 4 and 3

c – 4 and 5

d – 3 and 5

Answer: c

Explanation: Because bits required to store letter only i.e 15 letters=2^4 which means 4bits isrequired. Similarly for ANY CHARACTER (including letters)i.e 15+8+1=24 =2^5 ie 5 bits

required. So 4 and 5 bits required.

## 32 – Parul takes as input two numbers: a and b. a and b can take integer valuesbetween0 and 255. She stores a, b and c as 1-byte data type. She writes the following code statement to process a and b and put the result in c.c = a + 2*b To her surprise her program gives the right output with some input values of aand b,while gives an erroneous answer for others. For which of the following inputs will it give a wrong answer?

1.a = 10 b = 200

2. a = 200 b = 10

3. a = 50 b = 100

4. a = 100 b = 50

Answer: 1

Explanation:For OPTION 1: 10+ 2*200 = 410 (out of range), integer range is 0 to 255OPTION 2: c = 200+2*10= 220 OPTION 3 c = 50+2*100= 250OPTION 4 : c = 100+ 2*50= 200

## 33 – Prashant takes as input 2 integer numbers, a and b, whose value can bebetween0 and 127. He stores them as 7 bit numbers. He writes the following code to process these numbers to produce a third number c.c=a-b In how many minimum bits should Prashant store c?

a – 6 bits

b – 7 bits

c – 8 bits

d – 9 bits

Answer: c

Explanation: In the above problem he did not mentioned any -ve values and valuesbetween0 to127. Max value of c =127-0 =127. so 2^7 = 128.But in case c= 0-127 = -127.So to store this value we want 8 bytes. (1 bit is used to represent the signed value).

## 34 – Ankita takes as input 2 integer numbers, a and b, whose value can be between 0and 31, He Stores them as 5 bit numbers. He writes the following code to process these numbers to produce a third number c.c = 2*(a – b)In how many minimum bits should Ankita store c?

a – 6 bits

b – 7 bits

c – 8 bits

d – 9 bits

Answer: b

Explanation:c = 2*(a – b)lowest number will be generated when a=0 and b=31c= 2*(0-31)= -62`highest number will be generated when a=31 and b=0c= 2*(31-0)= 62Range= -64 to 64Bits required=7

## 35 – A character in new programming language is stored in 2 bytes. A string is represented as an array of characters. A word is stored as a string. Each byte in the memory has an address. The word “Mahatma Gandhi” is stored in the memory with starting address 456. The letter ‘d’ will be at which memory address?

1 – 468

2 – 480

3 – 478

4 – 467

Answer: 3

Explanation: Its start from 0 not 1 so d is at 11th position and an empty space is also aspace 456 + 11*2= 478.

## 36 – What will be the output of the following pseudo-code statements:

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

Answer: d

Explanation: b = a/d=456/10=45.6 it will be rounded off to 45 as the variable b isdeclared asinteger. Now c=456-45=411

## 37 – What will be the output of the following pseudo-code statements:

## integer a = 984, b, c, d =10 print remainder(a,d) // remainder when a is divided by da = a/dprint remainder(a,d) // remainder when a is divided by d

a – 4 8

b – Error

c-84

Answer: a

Explanation: Here for first statement : print remainder(a,d), we read it as (a%d) =984%10=4so ans for first statement is 4

For the second statement : (a/d)=984/10=98.4so a=98.4, but a is considered as integer so it is taken as 98so now a=98

For the third statement : print remainder (a,d)we take it as (a%d)=98%10=8 //i.e result from second statement a=98so ans for third statement is 8so we get 4 and 8

## 38 – What will be the output of the following code statements?

## integer a = 50, b = 25, c = 0print ( a > 45 OR b > 50 AND c > 10 )

a – 1

b – 0

c – -1 (minus 1

d – 10

Answer: a

Explanation: a>45 i.e true b>50 i.e false c>10 i.e absolutely false according to given data so by this we get 1+0*0=1

## 39 – What will be the output of the following code statements?

## integer a = 10, b = 35, c = 5 print a * b / c – c

a – 65

b – 60

c – Error

d – 70

Answer: a

Explanation lL->R (a * b / c – c= 10*35/5-5350/5-570-5=65

## 40 – Integer a = 40, b = 35, c = 20, d = 10

## Comment about the output of the following two statements:print a * b / c – dprint a * b / (c – d)

1 – Differ by 80

2 – Same

3 – Differ by 50

4 – Differ by 160

Answer: 1 Explanation40*35/20-10= 1400/20-10 = 70-10=6040*35/(20-10)=1400/10=140140-60=80integer a = 60, b = 35, c = -30

## 41 – What will be the output of the following two statements: print ( a > 45 OR b > 50 AND c > 10 )print ( ( a > 45 OR b > 50 ) AND c > 10 )

a – 0 and 1

b – 0 and 0

c – 1 and 1

d – 1 and 0

Answer: a

Explanation:-60 > 45 OR 35 > 50 AND c -30 > 10=> 1 OR 0 and 0 =>1(because in OR operator if first expression is true then condition is true) (45 OR 35 > 50 ) AND c -30> 10 => 1 AND 0 =>0

## 42 – What will be the output of the following pseudo-code statements: integer a =984, b=10

## //float is a data-type to store real numbers.float cc=a/bprint c

a – 984

b – 98.4

c – 98.000000

d – error

Answer: c Explanation:-Because c is float.

## 43 – Smriti wants to make a program to print the sum of square of the first 5 whole

## numbers (0…4). She writes the following program:integer i = 0 // statement 1 integer sum = 0 // statement 2while ( i < 5 ) // statement 3{ sum = i*i // statement 4 i = i + 1 // statement 5}print sum // statement 6Is her program correct? If not, which statement will you modify to correct it?

1 – No error, the program is correct.

2 – Statement 1

3 – Statement 4

4 – statement 6

Answer: 3

Explanation: Statement 4 should be sum=sum + i*i;

## 44 – Shashi wants to make a program to print the sum of the first 10 multiples of5.She writes the following program, where statement 5 is missing:integer i = 0integer sum = 0 while ( i <= 50 ) { sum = sum + i — MISSING STATEMENT 5 — } print sum Which of the following will you use for statement 5?

a) i = 5

b) i = 5 * i

c) i = i + 1

d) i = i + 5

Answer: d

Explanation: Multiple of 5will be 5,10(5+5),15(10+5)..

## 45 – Shantanu wants to make a program to print the sum of the first 7 multiples of6.He writes the following program:integer i = 0 // statement 1 integer sum // statement 2while ( i <= 42 ) // statement 3{ sum = sum + i // statement 4 i = i + 6; } print sum // statement 6Does this program have an error? If yes, which one statement will you modify to correct the program?

1 – Statement 1

2 – Statement 2

3 – Statement 3

4 – Statement 4

Answer: 2

Explanation: – Sum should be initialized sum=0;

## 46 – Bhavya wants to make a program to print the sum of all perfect squares, where the value of the squares go from 0 to 50. She writes+ the following program: integer i = 1, a // statement 1integer sum = 0while ( a < 50 ) // statement 2{ sum = sum + a // statement 3 i = i + 1 a = ( i * i ); // statement 4} print sum Does this program have an error? If yes, which one statement will you modify to correct the program?

a – Statement 1

b – Statement 2

c – Statement 3

d – Statement 4

e – No error

Answer: a

Explanation: Variable “a” should be initialized in statement 1.

## 47 – 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?

1 – An interpreter

2 – A compiler

3 – A cross-compiler

4 – Linker

Answer: 3

Explanation: Cross compiler is capable of creating executable code for platform otherthanone on which it is running.

## 48 – 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?

1 – Syntactical error 2 – Run-time Error 3 – Logical Error 4 – None of these

Answer: 3

Explanation: It would be a logical error. Factorial can’t be computed after a certain range

after 40 or 50for eg: because number will be so large that it will exceed boundary of even long double data type. It’s like divide by zero error, you give factorial of 60 to the program, it can’t compute it.

## 49 – 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?

1 – Compiler, Interpreter2 – Interpreter, Compiler 3 – Compiler, Compiler4 – Interpreter, Interpreter

Answer: 2

Explanation: Reshama debug cycle should be minimum. So, let her debug with aninterpreter.Mohammad wants to run multiple times. So, he may use different inputs. So, the codeneedsto be compiled every time. So, give him a compiler.

## 50 – Tarang writes an efficient program to add two upper triangular 10X10matrices(elements on diagonal retained). How many total additions will his program make?

a) 100 b) 55 c) 25 d) 10

Answer: b

Explanation : Assume an example of two upper triangular 2*2 matrix.|1,1| |1,1| total additions in this case will be 3, two additions in first row |0,1| |0,1| and one in second rowsimilarly in case of two upper triangular 3*3 matrix.|1,1,1| there will three addition operation for row one, two addition ops for row |0,1,1| second, and one add opp. for row third which adds up to 3+2+1, therefore |0,0,1| for 10*10 matrix no of opps will be 10+9+8+7+6+5+4+3+2+1=55

## 51.Pankaj and Mythili were both asked to write the code to evaluate the following expression: a – b + c/(a-b) + (a-b)2Pankaj writes the following code statements (Code A):print (a-b) + c/(a-b) + (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?

1 – Code A uses lesser memory and is slower than Code B

2 – Code A uses lesser memory and is faster than Code B

3 – Code A uses more memory and is faster than Code B

4 – Code A uses more memory and is slower than Code B

Answer: 1

Explanation: Let time for single operation be t, and memory space for single variable be m;For code A:8 operations will be done between 2 variables and 3 variables are used to store the values i.e.a, b, cso time to run code A= 8t , and memory space = 3mFor code B:4 operations are done between 2 variables , and 4 variables are used. so time to run codeB=4t,memory space =4mComparing 2 codes, we see that code A will take more time and less memory than codeB.

## 52 – Vikram wants to write a program which checks whether the inputted number is divisible by any of the first 6 natural numbers (excluding 1). He writes the following efficient code for it. int number, n = 2, is divisible=0 input number while ( n <=6) // Statement 1{ if ( remainder (number, n) == 0) is divisible = 1 end n = n+1 // Statement 2}if (is divisible equals 1) print “It is divisible” else print “It is not divisible” end Vikram takes the program to Hari. Hari tells Vikram that though the code is correct,it can be made more efficient. Hari modifies a single statement and makes the code more efficient. Which statement does he modify and how?

1 – Statement 1 is changed to: while (n <=6 AND isdivisible=0)

2 – Statement 1 is changed to: while (n <=6 OR isdivisible=0)

3 – Statement 1 is changed to: while (isdivisible=0)

4 – Statement 2 is changed to:n=n+2

Answer: 1

Explanation : As until the value of isdivisible not becoming 1 we have to continue theprocessbut when the value of isdivisible become 1 we need not to check further.

## 53 – Geetika writes a piece of code, where a set of eight lines occur around 10times in different parts 01 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.

1 – Code A

2 – Code B

3 – Code A and Code B will run with the same speed

4 – None of these

Answer: 2

Explanation: Code B has function. Execution of the function will be faster as compare to

normal statements.

## 54 – Worm is made up of two programs. which are__________ and **__**

**__**1 – grappling hook and main program

2 – main program and secondary program

3 – grappling hook and secondary program

Answer: 1

Explanation: Worm is made up of two program a grappling hook(also called bootstrap or

vector) program and the main program .The grappling hook is consisted of 99 lines of ccodecompiled and run on each machine it accessed . Once established on computer systemunderattack, the grappling hook connected to machine where it originated and upload a copyofmain worm onto the hook system. The main program processed to search for other machine to which the newly infected system could connect easily.

## 55 – Which of the following options will help in implementing the structure of at elephone answering system where the calls are answered in the order they are received in i.e. the call that has waited the longest is provided with highest priority?

1 – Binary Trees

2 – Heaps

3 – m-way Trees

4 – Binary Search Tree

Answer: 2

Explanation: Because heap data structure is a priority queue which gives importance topriority

## 56 – 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?

1 – Compiler

2 – Interpreter

3 – Assembler

4 – Simulator

Answer: 4

Answer: Simulator is used for creating virtual motorola processor in pentium computer.

## 57 – 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( ) ?

a. 12 -8

b. 13 -8

c. 12 8

d. 13 8

Answer: b

Explanation: Because values pass by reference so the updated value is in the calculate function A=13, b=-8

## 58 – Afzal writes a piece of code, where a set of three lines occur around 10 times indifferent parts of the program. What programming concept can he use to shorten his program code length?

1 – Use for loops

2 – Use functions

3 – Use arrays

4 – Use classes

Answer: 2

Explanation: Because function is used for reusability. Function is a block of statementsthatcan be called multiple times and at any place in the program.

## 59 – 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 ( )?

a. 80

b. 40

c. 32

d. 72

Answer: 2

Explanation: Modify function return 30 and thus calculate function c become 40

## 60 – Consider the following code: function modify(w,u){w=w+2u=u-3return (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 ( )?

a. 12 17

b . 10 17

c. 12 20

d. 10 20

Answer: b

Explanation: As b is passed by ref so its updated value will be there 17

## 60 – Consider the following function: function run( ){integer a = 0 // Statement 1while (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?

1 – Statement 1

2 – Statement 2

3 – Statement 3

4 – Statement 4

Answer: 4

Explanation: As the c variable scope is not there so it generates an error.

## 61 – 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

3 – Assembly Language

4 – System Language

Answer: 2

Explanation: As computer accept everything in binary format so its machine code

## 62 – If you want to write a function that swaps the values of two variables, you must pass them by:

1 – Value only 2 – Reference only 3 – Either A or B 4 – Neither A nor B

Answer: 2

Explanation: By reference the values are updated everywhere

## 63 – Consider the following code: if (condition 1){ if (condition 2) { // Statement A } else if(condition 3) { // Statement B } else { // Statement C }}else if(condition4){ // Statement D }else{ // Statement E}}Which of the following conditions will allow execution of statement C?

1 – condition1 AND condition3

2 – condition1 AND condition4 AND !condition2

3 – NOT(condition2) AND NOT(condition3)

4 – condition1 AND NOT(condition2) AND NOT(condition3)1.2.

Answer: 4

Explanation: Statement c only executes if condition 1 is true but condition 2 andcondition 3 isfalse.

## 64 – Consider the following code:

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

1 – NOT(condition2) AND NOT(condition3)

2 – condition1 AND condition4 AND NOT(condition2) AND NOT(condition3)

3 – condition1 AND condition2 AND condition4

4 – NOT(condition1) AND condition2 AND NOT(condition4)

Answer: 3

Explanation: As the condition 1, condition 2 and condition 3 become true the statementA and D will print

## 65 – What does the following function do? function operation (int a, int b){if (a < b){return operation(b, a) }else{ return a }}

1 – Returns the max of (a,b)

2 – Returns the min of (a,b)

3 – Loops forever

4 – Always returns the second parameter

Answer: 1

Explanation: It returns the maximum of two numbers a, b

## 66 – What does the following function do? function operation (int a, int b){if (a > b){return operation(b, a) }else{ return a; } }

1 – Always returns the first parameter

2 – Returns the min of (a,b)

3 – Returns the max of (a,b)

4 – Loops forever

Answer: 2

Explanation: It returns the minimum of two number

## 67 -function g(int n){ if (n > 0) return 1;else return -1;}function f(int a, int b){ if (a > b) return g(b-a); if (a < b) return g(a-b); return 0;}If f(a,b) is called, what is returned?

a. Always -1

b. 1 if a > b, -1 if a < b, 0 otherwise

c. -1 if a > b, 1 if a < b, 0 otherwise

d. 0 if a equals b, -1 otherwise

Answer: d

Explanation: In every case if a and b have different value always

## 68 -function g(int n)

## {if (n > 0) return 1;else return -1;} function f(int a, int b){if (a > b) return g(a-b);if (a < b) return g(b-a); return 0;}If f(a,b) is called, what is returned?

a. 1 if a > b, -1 if a < b, 0 otherwise

b. Always +1

c. 0 if a equals b, +1 otherwise

d. -1 if a > b, 1 if a < b, 0 otherwise

Answer: c Explanation: Always return the 1 if a and b different value, if same then 0

## 69 -function g(int n){if (n > 0) return 1; else return -1;} function f(int a, int b){if (a > b) return g(a-b);if (a < b) return g(-b+ a); return 0; }If f (a, b) is called, what is returned?

a. Always +1

b. 1 if a > b, -1 if a < b, 0 otherwise

c. -1 if a > b, 1 if a < b, 0 otherwise

d. 0 if a equals b, -1 otherwise

Answer: b

Explanation: If both same answer is 0 then a>b then 1 otherwise -1

## 70 -function g(int n)

## {if (n > 0) return 1;else return -1;} function f(int a, int b){if (a > b) return g(b-a);if (a < b) return g(-a+b); return 0; }If f(a,b) is called, what is returned?

a. Always +1

b. -1 if a > b, 1 if a < b, 0 otherwise

c. 1 if a > b, -1 if a < b, 0 otherwise

d. 0 if a equals b, -1 otherwise

Answer: b

Explanation: if a>b then -1 otherwise a<b 1 rest 0

## 71 – Consider the following code:for i= m to n increment 2{print “Hello!”} Assuming m < n and exactly one of (m, n) is even, how many times will Hello be printed?

a. (n – m + 1)/2b. 1 + (n – m)/2c. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is oddd. (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd

Answer: a

Explanation: As increment is 2 so loop maximum run half (N number from m)

## 72 – Consider the following code:for i= m to n increment 2{print “Hello!”} Assuming m < n and (m,n) are either both even or both odd, How many times will Hello be printed?

a. (n – m + 1)/2

b. 1 + (n – m)/2

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

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

Answer: b

Explanation: Number of term of an AP=N=(last-a)/d+1=>last=n, a=m, d=difference in series(Where m=1 and n=7).

## 73 – Assuming n > 2, what value does the following function compute for odd n?function f (int n){if (n equals 1){ return 1}if (n equals 2){ return f(n-1) + n/2}return f(n-2) + n;}

a. 1 + 2 + 3 + 4 + … + n

b. 1 + 3 + 5 + 7 + … + n

c. n/2 + (1 + 3 + 5 + 7 + … + n)

d. 1 + (1 + 3 + 5 + 7 + … + n)

Answer: b

Explanation: Given that n is odd and >2, The list generate is 1+3+5+7…+n

## 74 – Assuming n > 2, what value does the following function compute for even n?

## int f (int n){if (n equals 1){ return 1}if (n equals 2){ return f(n-1) + n/2} return f(n-2) + n }

a. 1 + 2 + 3 + 4 + … + n

b. 1 + (2 + 4 + 6 + 8 + … + n)

c. 1 + n/2 + (4 + 6 + 8 + … + n)

d. 2 + 4 + 6 + 8 + … + n

Answer: d

Explanation: Suppose n=4 than both if condition will false and the last statement will be executed. Return f(4-2) +2 Now recursive function will call again Now n=2 statement will be executed Return f(2-1)+2/2Now recursive function will call again Return 1 At the end we will get 2+4

## 75 – Consider the statement

## while (a < 10.0){a = a*a}Assuming a is positive, for what value of a will this code statement result in an infinite loop?

- a < 1.0
- 2. a < sqrt(10)
- 3. a > sqrt(10)
- 4. a = 0

Answer: 1

Explanation: In option 2 3 and 4 the loop become finite or none

## 76 – int area(double radius){ return PI *radius* radius;} Which of the following is always true about the function area?

1 – It returns the area of a circle within the limits of double precision.

2 – It returns the area of a circle within the limits of the constant PI.

3 – It returns the area of a circle within the limits of precision of double, or the constantPI,whichever is lower

4 – None of the above.

Answer: 4

Explanation: As return type of function is integer

## 77 – What does this function compute for positive n?function f(int n){if (n equals 1) { return 1}else{ return f(n-1)/f(n-1) + n}}

a. 1 + n

b. 1 + 2 + 3 + … + n

c. 1 + n, if n > 1, 1 otherwise

d.None of the above

Answer: c

Explanation: As the f(1)/f(1)+2 become: 1+2 in all cases.

## 78 – How will 47 be stored as an unsigned 8-bit binary number?

a. 10111101

b. 00101111

c. 10111000

d. 00101101

Answer: b

Explanation: 32+8+4+2+1=47

## 79 – An integer X is saved as an unsigned 8-bit number, 00001011.What is X?

a. 22

b. 11

c. 10

d. None of these

Answer: b

Explanation: 00001011= 0*2^7+0*2^6+0*2^5+0*2^4+1*2^3+0*2^2+1*2^1+1*2^0

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

1 – Writing the program in the programming language

2 – Writing a step-by-step algorithm to solve the problem.

3 – Compiling the libraries required.

4 – Code debugging

Answer: 2

Explanation: first Algorithm then try to code

## 81 – Rajesh implements queue as a singly-linked linked list. The queue has nelements.The time complexity to ADD a new element to the queue:

a. (1)

b. (log2 n)

c. (n)

d. (n log2 n )

Answer: a

Explanation: Because it follows FIFO. NOTE – in normal case insertion andDeletion in Linked list take O(1) time.

## 82 – The time required to insert an element in a stack with linked list implementation is

a. (1)

b. (log2 n)

c. (n)

d. (n log2 n )

Answer: a

Explanation: In stack element is added at the top of the stack .To implement stack usinglinklist ,element will always be added at the end. So, it will take O(1) time.

## 83 – What is the term used to describe the situation, when a function in the baseclassis redefined in inherited class?

1 – Inheritance

2 – Overriding

3 – Overloading

4 – Encapsulation

Answer: 2

Explanation: Overriding is the process of redefining parent class method in child class with same signature. In this process, child class method will override the method of parent class.

## 84 – Consider the given statements regarding Arrays-

## 1 – Arrays provide a linear medium to store data.

## 2 – Arrays provide a non indexed structure.

## 3 – All the elements in Array depend on the location of the other elements of the Array.

## Which of the above statements is/are true?

a. Only 1

b. Both 1 and 2

c. Both 1 and 3

d. 1, 2 and 3

Answer: c

Explanation: An array is a collection of homogeneous data elements stored in contiguous memory locations

## 85 – 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?

1 – Integer

2 – Boolean

3 – Float

4 – Character

Answer: 2

Explanation: Boolean data type indicates only two values : true and false.

## 86 – Which of these is not a primitive data type?

1 – Integer 2 – character 3 – Boolean 4 – array

Answer: 4

Explanation: array is a derived data type that is created with the help of basic datatypes.

## 87 – In an implementation of a linked list, each node contains data and address. Which of the following can the address field possibly contain?

1 – Address of the next node in sequence

2 – Its own address

3 – Address of the last node

4 – Address of the first node

Answer: 1

Explanation: In linked list, each node contains two parts: data and address. Data part contains data available in that node & Address part contains address of the next node which is needed to traverse.

## 88 – The following operation are performed on an empty stack “A”PUSH(1)PUSH(2)POPPUSH(5)PUSH(6)POPWhat will stack contain after these operations? Note: The top of the stack is underlined in the option below)

a. 5 6

b. 1 2

c. 1 5

d. 6 6

Answer: c

Explanation: stack used LIFO (Last In First Out) technique. All elements are insertedfrom topof stack.

## 89 – What is the space complexity of a program?

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.

4 – Amount of memory required for the program to compile.

Answer: 3

Explanation: Space complexity is a measure of the amount of working storage analgorithmneeds. That means how much memory, in the worst case, is needed at any point in thealgorithm. This is essentially the number of memory cells which an algorithm needs.A good algorithm keeps this number as small as possible, too.

## 90 – Srishti writes a program to find an element in the array A[5] with the following elements in order: 8 30 40 45 70. She runs the program to find a number X.X is found in the first iteration of binary search. What is the value of X?

a. 40

b. 8

c. 70

d. 30

Answer: a

Explanation: In binary search technique, mid point is searched first of all.Then, Left and Right nodes are traversed.

## 91 -Function MyDisplay(string Mystr) //statement 1{Print “Hello!”Print MystrReturn 1 //statement 2}function main() //statement 3{String str=”Mickey”MyDisplay(str) //statement 4}Consider the given code to print a name on the screen.Which statement will generate an error or warning message?

1 – Statement 1

2 – Statement 2

3 – Statement 3

4 – Statement 4

Answer: 2

Explanation: Non returning function should not use “return” statement in its body.

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

1 – Data members

2 – Member functions

3 – Constructors and destructors

4 – Data members and member functions

Answer: 4

Explanation: A parent class can have both data members and member functions and it is possible to inherit them in new class.

## 93 – Which of the following options is responsible for taking files and objects from different locations and combining them for execution?

1 – Linker

2 – Loader

3 – Interconnecting compiler

4 – Interpreter

Answer: 1

Explanation: Linker is responsible for combining multiple object files, library files in to single executable file.

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

1 – It has no elements

2 – It has one element

3 – There is an error

4 – None of the above

Answer: 2

Explanation: It has one element, because it is circular linked list. front end= rear end, but not equal to null.

## 95 – Suhana 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 bean efficient way of debugging?

1 – Compile the whole code and step into it line by line

2 – Use an interpreter on the first 25 lines

3 – Compile the whole code and run it

4 – None of these

Answer: 4

Explanation: Logical errors can’t be compiled nor they can be interpreted.

## 96 – What will be the input to the second pass, if the list before starting the radix sort is: 729,150,123,931,348,517 ?

a. 150,123,348,517,729,931

b. 150,931,123,517,348,729

c. 517,729,123,931,348,150

d. 123,150,348,517,729,931

Answer: d

Explanation: Radix sort technique sorts the digits of numbers on its base. First of all, first digit from right side is checked. Then, second digit from right side is checked and so on.

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

a. 6

b. 7

c. 10

d. None of these

Answer: b

Explanation: In queue initially the both Front and Rear assigned by the value -1 means the queue is empty. The size of the queue is 10 (array index no from 0 to 9).ADD 1 it will increment both Front and Rear (in case of first element)DELETE deletion of element set the Front and Rear to -1(queue is empty)ADD 2 Front = 0 ,Rear = 0ADD 3 Front = 0 ,Rear = 1ADD 4 Front = 0 ,Rear = 2DELETE Front = 1 ,Rear = 2DELETE Front = 2 ,Rear = 2Now the empty location in the queue is 7 so the maximum capacity of queue is 7 . In spite 2 location is empty in left side of the last element 4 but queue cannot access these location as the front on the location 2 this is the disadvantage of simple to queue to overcome this problem circular queue is implemented.

## 98 – A tree has 5 levels and each has either 4 children or no children. All nodes on the same level have the same number of children. How many nodes are there in the tree?(Root is Level 1)

a. 341 b. 256 c. 1024 d. None of these

Answer: a

Explanation: Answer will be option A. 1 + 4 + 16 + 64 + 256

## 99 – If the depth of a tree is 3 levels, then what is the size of the Tree?

a. 2 b. 4 c. 6 d. 8

Answer: d

Explanation: formula is 2n

## 100 – Consider an array on which bubble sort is used. The bubble sort would compare the element A[x] to which of the following elements in a single iteration?

1 – A[x+1]

2 – A[x+2]

3 – A[x+2x]

4 – All of these

Answer: 1

Explanation: In the bubble sort First element is compare with the second if 1st element isgreater then replace itthis step is repeated and lead to largest element at the last position(called one pass)