AMCAT Computer Programming Previous Year Paper

AMCAT PREVIOUS YEAR QUESTIONS PAPER - COMPUTER PROGRAMMING


1.       1. Null function is also known as a. Anonymous Function b. Generic Function c. Void Function d. Null operator Ans.D 2. There are two loops which are nested. This implies which of the following a. Two loops, one after the other b. Two loops, one inside the other c. One loop two different iteration counts d. Two loops with same iteration count Ans.B 3. Shravanti writes the following program. 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 } What will be the output of the program? a. 0 b. 0 3 c. 0 d. 0 3 6 0 3 0 3 6 0 3 6 0 3 6 9 0 3 6 9 0 3 6 9 12 Ans. C 4. What is the term used to describe the situation,when a function in the base class is redefined in inherited class? a. Inheritance b. Overriding c. Overloading d. Encapsulation Ans.B 5. 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 Ans.D 6. Consider a binary tree implementation. The root address is stored in variable root. Given the address of a node is variable node, its value, right and root could node address can be accessed using the following statements respectively node-> value ,node -> right, node-> left. Srikanth writes the following function to do a preorder traversal of the tree. function preordertraverse(n0de) { print node -> value if(Conditon X) { preordertraverse(node ->left) } if(Condition Y) { preordertraverse(node ->right) } return } What is the Condition X and Condition Y ? a. Condition X: node -> left is not equal null b. Condition X: node -> right is not equal null,Condition Y:node -> right is not equal null,Condition Y:node -> left is not equal null c. Condition X: node -> left is equal null d. Condition X: node -> right is equal null, Condition Y:node -> right is equal null, Condition Y:node -> left is equal null. Ans.A 7. In breadth-first search,which of the following options is true? a. Beginning from a node,first all its adjacent nodes are traversed. b. Beginning from a node,each adjacent node is fully explored before c. Traversing the next adjacent node. d. Beginning from a node , nodes are traversed in cyclic order. e. None of these. Ans.A 8. Sruti is making a questionnaire of True-False question. She wants to define a data-type which stores the response of the candidate for the question. What is the most suited data type for this purpose? a. Integer B. Boolean c. float d. character Ans.B 9. Which of these is not a data type? a. Integer B. character C. Boolean D. array Ans.D 10. A full binary tree with n leaves contains a. 2n+1 nodes b. log2n nodes C. 2n-1 nodes D. 2n nodes Ans.A


11.  In an implementation of a linked list, each node contains data and address. Which of the following could the address field possibly contain?
A. Address of next node in sequence   B. It’s own address 
C. Address of the last node                   D. Address of the first node

Ans. A


12.  Parthiv has included several classes and their subjects in his project. Now he wants to use something that will hold all these objects (of different classes). Which of the following options provides him with the best iterative?

A. Store them in database           B. Final class            C. Generic class       D. Anonymous class

Ans.C


13. Shristhi 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 the missing statement.
a.       return factorial(n-1)                     B. return n*factorial(n)     C. return n*(n-1)     D. return n*factorial(n-1)

Ans.D


14.       Shasi wants to make a program to print the sum of the first 10 multiples of 5. She writes the following program, where statement 5 is missing.

integer i=0
integer sum=0
while ( i <= 50)

                                 sum =sum+1
                                - - MISSING STATEMENT - -
}
print sum
Which of the following options will you use for statement 5?
A. i = 5                   B. i = 5 *I              C. i = i + 1                             D. i = i + 5

Ans.D


15.       Consider the following code:

if(condition 1)
{
                                if(condition 2)
                                {  
// Statement A 
}
                                 Elseif (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?

A. condition1 AND condition 3
B. condition1 AND condition4 AND NOT (condition2)
C. NOT (condition2) AND NOT (condition3)
D. condition1 AND NOT(condition2) AND NOT(condition3)

Ans.D


16.A full binary tree with n non-leaf nodes contains

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

Ans. C


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

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

Ans.A


18. Aina wants to use a sorting technique to sort a list of numbers such that the running time of the sorting technique that she uses won’t affected by pre-order of the elements. Which of the following sorting techniques should she use?

A. Merge Sort                    B.  Bubble Sort                  C. Insertion Sort               D. Selection Sort
Ans. Not known please write into Comments and will be added here for students reference.

19. While calculating time complexity of an algorithm, the designer concerns himself/herself primarily with the run time and not the compile time. Why?

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

Ans.D


20. Pankaj and Mythili were both asked to write the code to evaluate the following expression.

a-b + c/(a-b) + (a-b)2       
1.       Pankaj writes the following code statements (Code A)
print (a-b) + c/(a-b) + (a-b) * (a-b)
2.       Mythili writes the following code statements (Code B)
d = (a-b)
print d + c/d + d*d

If the time taken to load in a variable, for addition, multiplication or division between two operands is same , which of the following is true?

A.      Code A uses lesser memory and is slower than Code B.
B. Code A uses lesser memory and is faster than Code B.
C. Code A uses more memory and is faster than Code B.
D. Code A uses more memory and is slower than Code B.

Ans.A


21. Which of the following sorting algorithm yield approximately the same worst-case and average-case running time behaviour in O (n log n)? A. Bubble sort and Selection sort B. Heap sort and Merge sort C. Quick sort and Radix sort D. Tree sort and Median-of-3 Quick sort Ans. B 22. Sujan 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? A. All numbers in one more list are more than 100, while in other are less than 100. B. The ordering of numbers with respect to magnitude in two lists has different properties. C. One list has all negative numbers, while the other has all positive numbers. D. One list contains 0 as element, while the other does not. Ans. B 24. 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 attribute is Herbivorous,colour and isNocturnal.She uses the object-oriented programming paradigm for this.How will she conceptualise the system? A. Class: Animal; objects: dog, lion and zebra; data members : isHerbivorous, colour and is Nocturnal B. Class : Animal; objects : isHerbivorous, colour and isNocturnal; data members : dog, lion and zebra C. Classes: dog, lion and zebra: objects: Animal; data members: isHerbivorous, colour and is Nocturnal D. None of these Ans. A 25. What is implied by the argument of a function? A. Variables passed to it when it is called B. The value is returns on execution C. The execution code inside it D. Its return type Ans. A 26. Tanuj writes the code for a function that takes as input n and calculates the sum of first n natural numbers. function { if(??) return 1 else return(n+sum(n-1)) end } Fill in?? in the code. A. n equals 1 B. n equals 2 C. n>=1 D. n>1 Ans. A 27. integer i,k,j,n==5 for i=n to 1 decrement 1 { for j=n to i+1 decrement 1 { Print blankspace } for k=1 to ((2*i)-1)increment 1 { print “*” } print end-of-line //takes the cursor to the nextline } What will be the output when the given code is executed? A. ***** B. ***** C. ***** D. * **** **** **** ** *** *** ***** *** ** ** **** **** * * ***** ***** Ans .C 28. Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the program. What programming concept can he use to shorten his program code length? A. Use for loops B. Use functions C. Use array D. Use classes Ans. B 29. Which of the following statements is true regarding the sorting and searching algorithms? A. Linear searching is faster than the most efficient sorting algorithm B. Linear searching is slower than the most efficient sorting algorithm C. Linear searching and the most efficient sorting algorithm take up almost same time D. Their complexities cannot be compared Ans. B 30. Stack is used for implementing A. Radix search B. Breadth first search C. Recursion D. None of these Ans. C


31. Consider the following: Class rocket { Private: integer height,weight public: //statement 1 function input(int a,int b) { height=a; weight=b; } } function main() { rocket rocket 1,rocket2 } What can we infer from this code? Choose the correct answer. A pseudo-code which is similar to that of c++ and self-explanatory. An accessible member function or data member for an object are accessed by the statement object name, function name or object name data member name respectively. A. rocket is a class with rocket 1 and rocket2 as its objects.height and weight are attributes of a rocket. B. rocket is a class with rocket1 and rocket2 as its attributes.height and weight are objects of the class rocket. C. rocket is a class with rocket1,rocket2,height and weight as its attributes D. rocket is a class with rocket1, rocket2, height, weight as its objects. Ans- C 32. Vijay wants to print the following pattern on the screen: 1 1 2 1 2 3 He writes the following program: integer i=1 //statement1 while(i<=3) { int j //statement2 while(j<=i) //statement3 { print j print blank space j=j+1 //ststement4 } print end-of-line //takes the cursor to the nextline i=i+1 } Choose the correct answer: A. Statement 1 B. Statement 2 C. Statement 3 D. Statement 4 E. Program does not have error Ans - E 33. In an implementation of a linked list, each node contains data and address. Which of the following could the address field possibly contain? A. Address of next node in sequence B. It’s own address C. Address of last node D. Address of first node Ans- A 34. A sort, which uses the binary tree concept such that any number in the tree is larger than all the numbers in the sub tree below it, is called A. Selection sort B. Insertion sort C. Heap Sort D. Quick sort Ans - C 35. 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? A. It has no elements B. It has one element C. There is an error D. None of these Ans - B 36. Which of these is not a data type? A. Integer B. Character C. Boolean D. array Ans - D 37. A is an empty stack .The following operations are done on it. PUSH(1) PUSH(2) POP PUSH(5) PUSH(6) POP What will the stack contain after these operations?(top of the stack is underlined) A. 5 6 B. 1 5 C. 5 6 D. 1 5 Ans- B 38. A sorting algorithm traverses through a list, comparing adjacent elements and switching them under certain conditions. What is this sorting algorithm called? A. Insertion sort B. Heap sort C. Quick sort D. Bubble sort Ans-Bubble sort 39. What is the space complexity of a program? A. Amount of hard-disk space required to store the program B. Amount of hard-disk space required to compile the program C. Amount of memory required by the program to run D. Amount of memory required for the program to compile Ans. C 40. Which of the following data types does not belong to the category of abstract data types? A. Hash table B. Set C. Object D. Stack Ans Object



41. A data type is stored as an 6 bit signed integer. Which of the following options cannot be represented by this data type? Option 1 -12 Option 2 0 Option 3 32 Option 4 18 Ans -12 42. 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? 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 Ans B 43. Which of the following sorting algorithms yield approximately the same worst-case and average-case running time behaviour in O (n log n)? A. Bubble sort and Selection sort B. Heap sort and Merge sort C. Quick sort and Radix sort D. Tree sort and Median-of-3 Quick sort Ans. B 44. Zenab and Shashi independently write a program to find the mass of one mole of water, which includes mass of hydrogen and oxygen. Zenab defines the variables: integer hydrogen, oxygen, water //code A while Shashi defines the three quantities as: integer a,b,c //code B Which is a better programming practice and why? A. Code B is better because variable names are shorter B. Code A is better because the variable names are understandable and non-confusing C. Code A will run correctly, while code B will give an error. D. Code B will run correctly, while code A will give an error. Ans. B 45. Srishti writes a program to find an element in the array A[5] with the following elements in order: 8 30 40 45 70. She runs the program to find a number X. Xis found in the first iteration of binary search. What is the value of X? Choose the correct answer A. 40 B. 8 C. 70 D. 30 Ans. A 46. Consider the following pseudo-code Class rocket { Private Integer height, weight public: //Statement 1 function input (int a, intb) { height =a; weight =b; } } function main() { Rocket rocket1, rocket2 } Choose the correct answer. A pseudo-code which is similar to that of C+ and self-explanatory. An accessible member function or data member for object are accessed by the statement object name.function name or object name.data membername respectively. A. Rocket is a class with rocket1 and rocket2 as its objects. Height and weight are attributes of a rocket. B. Rocket is a class with rocket1 and rocket2 as its attributes. Height and weight are objects of the class rocket. C. Rocket is a class with rocket1, rocket2, height and weight as its attributes. D. Rocket is a class with rocket1, rocket2, height and weight as its objects. Ans A 47. There are two loops which are nested. This implies which one of the following? Choose the correct answer? A. Two loops, one after the other B. Two one inside the other C. One loop with two different iteration counts D. Two loops with one iteration counts Ans. B 48. Saloni writes the code for a function that takes as input n, an even integer and calculates the sum of 1st n natural numbers function sum (n) { if(n equals 2) return 2 else return ( n+ sum( n-1)) } She then calls the function by the statement, sum(30). How many times will the function sum be called to compute this sum? Choose the correct answer? A. 1 B. 30 C. 15 D. 16 Ans B 49. A derived class may inherit from the base class which of the following? (Consider assumptions as in c++) Choose the correct answer? A. Data members B. Member functions C. Constructors and destructors D. Both data members and member functions Ans. D 50. Shalini wants to programme to print the largest number out of 3 inputted numbers. She writes the following programme Int number 1, number 2, number 3, temp; Input number 1, number 2, number 3; If ( number 1 > number 2) Temp = number 1 Else Temp= number 2 End if If ( ??) // statement 1 Temp = number 3 End if Print temp Fill in the ?? in statement 1 ? Choose the correct answer? A. Number 3> number 2 B. Number 3> temp C. Number 3< temp D. Number 3> number 1 51. How many pointers will have to be changed when a new node is to be added in a linear linked list in the middle? A. 0 B. 1 C. 2 D. All the pointers will be changed Ans B 52. A variable cannot be used? Choose the correct answer A. Before it is declared B. After it is declared C. In the function it is declared in D. Can always be used Ans A 53. In which area of a class are data and function directly accessible outside the class? Choose the correct answer A. Public B. Private C. Protected D. None Ans A 54. Which of the following options is true regarding inheritance in Object Oriented Programming ? Choose the correct answer? A. There is reduced interaction with the hardware B. A class may are may not have any object C. Two are more functions can have the same name and number and type of arguments in a program D. Class- object relation can be changed at run time E. All of the above Ans E 55. A sort , which uses the binary tree concepts such that any number in the tree is a larger than all the numbers in the sub tree below it, is called? Choose the correct answer? A. Selection sort B. Insertion sort C. Heap sort D. Quick sort Ans. C 56. Every element of a data structure has an address and a key associated with it. A search mechanism deals with two or more values assigned to the same address by using the key. What is this search mechanism? A. Linear search B. Selection search C. Hash coded search D. Binary search E. None of this Ans. C 57. A complete binary tree with five levels has how many nodes? (root is level 1) Choose the correct answer? A. 15 B. 25 C. 63 D. 31 Ans C 58. Which of the following abstract data types can be used to represent many – to- many relations? Choose the correct answer? A. Tree B. Stack C. Graph D. Queue Ans A 59. Pragya sells footballs. She has a large container to store footballs which is closed from below. Footballs are piled one on top of the other in the box. When new balls are supplied, Pragya puts the balls in the box from the top. When a customer buys a ball, she delivers the ball at the top of the pile to the customer. Each ball has a code. She wants to store the ball codes in the data structure to keep track of her inventory. What data structure should she use? Choose the correct answer? A. Queue B. Stack C. Array D. Graph Ans B 60. The algorithm design technique used in quick sort algorithm is ? Choose the correct answer A. Dynamic programming B. Back tracking C. Divide and conquer D. Greedy search Ans. C
61. Sorting is not possible by using which of the following method? Choose the correct answer ? A. Insertion B. Selection C. Exchange D. Deletion Ans D 61. Sorting is not possible by using which of the following method? Choose the correct answer ? A. Insertion B. Selection C. Exchange D. Deletion Ans D 62. For the given array, find the arrangement of the elements after 3rd pass of selection sort. Assume that the array is being sorted in ascending order list ; 33,22, 11, 77, 66, 88, 55 A. 22, 11, 33, 66, 77, 55, 88 B. 11, 22, 33, 55, 66, 77, 88 C. 11, 22, 33, 55, 66, 88, 77 D. 11, 22, 33, 77, 66, 88, 55 63. For solving a problem, which of these in the 1st step in developing a working programme for it? Choose the correct answer? A. Writing the program in the programming language B. Writing the step by step algorithm to solve the problem C. Compiling the libraries required D. Code debugging Ans B 64. What is space complexity of a program? Choose the correct answer ? A. Amount of hard- disk space required to store the program B. Amount of hard- disk space required to compile the program C. Amount of memory required by program to run D. Amount of memory required for the program to compile Ans C 65.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 3 quantities as: Integer a, b, c // code B Which is the better programming practice and why? Choose the correct answer? A. Code B is better because variable names are shorter B. Code A is better because the variable names are understandable and non-confusing C. Code A will run correctly, while code B will give an error D. Code B will run correctly while code A gives an error Ans B 66. How can call to an overloaded function be ambiguous? A. By misspelling the name B. There might be two or more functions with the same name C. There might be two or more functions with equally appropriate signatures D. none of these Ans B 67. 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 Ans D 68. Function MyDisplay(string Mystr) //statement 1 { Print “Hello!” Print Mystr Return 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? A. Statement 1 B. Statement 2 C. Statement 3 D. Statement 4 E. This code will run without any error Ans A 69. What is implied by the argument of a function? A. The variables passed to it when it is called B. The value it returns on execution C. The execution code inside it D. Its return type Ans A 70. Consider the following pseudo-code Class rocket { private: Integer height,weight public: ///statement 1 function input(int a, int b) { height = a; weight = b; } } function main() { Rocket rocket 1,rocket 2 ; } What can we infer from this code? A. Rocket is a class with rocket 1 and rocket 2 as its objects. Height and weight are attributes of a rocket. B. Rocket is a class with rocket 1 and rocket 2 as its attributes .height and weight are objects of the class rocket. C. Rocket is a class with rocket 1, rocket 2, height and weight as its attributes. D. Rocket is a class with rocket1, rocket 2, height and weight as its objects. Ans A

71. Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the program. What programming concept can he use to shorten his program code length? A. use for loops B. use functions C. use arrays D. use classes Ans B 73. Shravanthi writes the following program: 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 } What will be the output of the program? A. 0 B. 0 3 C. 0 D. 0 3 6 0 3 0 3 6 0 3 6 0 3 6 9 0 3 6 9 0 3 6 9 12 74. A destructor may be invoked in which of the following situations? A. when the object is created B. when the object is assigned value 0 C. only at the end of the code D. when the scope of the object is over Ans D 75. Consider the given statement for their correctness with respect to stacks data structure 1. Stacks follow a LIFO approach 2. Stacks are used to convert binary numbers to corresponding decimal numbers. 3. Stacks use two pointers for performing PUSH and POP respectively A. TTF B. TTT C. TFF D.FTF Ans D 76. 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 prescedence (high to low).operates in the same row have the same precedence: (.) */ + - AND OR. For operates with equal precedence is from left-to-right in expression. A. differ by 80 B. same C. differ by 50 D. differ by 160 Ans A 77. Stack is useful for implementing. A. Radix search B. Breadth first search C. Recursion D. None of these Ans C 78. Which of the following options gives the lower bound on running time for an algorithm? A. Best case complexity of the algorithm B. Average case complexity of the algorithm C. Worst case complexity of the algorithm D. Number of iterations taking place in the algorithm Ans C 79. A queue is implemented as a (single linked) linked-list. Each node has an element and pointer to another node. Rear and Front contain 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? A. It has no elements B. It has one element C. There is an error D. None of these Ans B 80. Which of the following options describes a tree? A. An unconnected graph B. A connected graph C. A connected acyclic graph D. A complete graph Ans C
81. A full binary tree with n non-leaf nodes contains.
A. (log n) nodes                                B. n+1 nodes                      C. 2n+1 nodes                   D. 2n nodes

Ans C
82. Every element of a data structure has an address and a key associated with it. A search mechanism deals with two or more values assigned to the same address by using the key. What is this search mechanism?
A. Linear Search                  B. Binary Search                  C. Hash Coded Search             D. None of these

Ans C

83. While calculating time complexity of an algorithm, the designer concerns himself/herself primarily with the run time and not the compile time why?
A. Runtime is always more than compile time     B. Compile time is always more than run time
C. Compile time is a function of run time               D. A program needs to be compiled once but can run several times.

Ans D

84. Shahana 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?
    A. Compile the whole code and step into it line by line                               B. Use an interpreter on the first 25 lines
    C. Compile the whole code and run it                                                                 D. None of these

Ans B

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



86. Sorting is not possible by using which of the following methods?
A.      Insertion                         B. Selection                        C. Exchange                             D. Deletion

Ans D


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

Ans D

88.  In an implementation of a linked list, each node contains data and address. Which of the following could the address field possibly contain? Choose the correct answer?
A. Address of next node in sequence   B. Its own address   C. Address of last node    D. Address of first node

Ans A

89. A variable cannot be used. Choose the correct answer
A. Before it is declared      B. After it is declared    C. In the function it is declared in   D. Can always be used

Ans A

90. 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? Choose the correct answer?

A. Faster execution        B. Lower memory requirement         C.  Correction of errors        D. Better readability

Ans D

91. Choose the correct answer?
Question:  Consider the given declarations
Integer (*arr1)[10]
Integer *arr2[10]
Which of the following statements is true regarding the above?
A.      Arr1 is pointer to an array of integers                                     B. Arr2 is array of integer pointers
C. Arr1 and arr2 both are pointers to array of integers       D. Arr1 and arr2 are arrays of integer pointers
E. Arr1 is array of integer pointers                                                 F. Arr2 is pointer to an array of integers

92. 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, number2
If(??)  //statement 1
Print number1
Else
Print number2
End if
Fill in the?? in statement 1. Choose the correct answer
A.      Number1 > number2   B. Number2 > number1 C. Number2 equals number1 D. Number1 <= number2

93. A derived class may inherit from the base which of the following?  (Consider assumptions as in c++) Choose the correct answer?
A. Data members                                                                     B. Member functions  
C. Constructions and destructors                                      D. Both data members and member functions.

94. 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?  Choose the correct answer
A. Integer                      B. Boolean                            C. Float                             D. Character

95. Which of the following options is responsible for taking files and objects from different locations and combining them for execution?
A. Linker                       B. Loader                     C. Interconnecting compiler      D. Interpreter

96. Shristi 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. Choose the correct answer?
A.      Return factorial(n-1)          B. Return n*factorial(n)                 C. return n*(n-1)              D. return n*factorial(n-1)

97. A sort, which uses the binary tree concept such that any number in the Tree is larger than all the numbers in the sub tree below it is called Choose the correct answer
A. Selection sort            B. Insertion sort                        C. Heap sort                D. Quick sort

98. Shashi wants to make a program to print the sum of first 10 multiples of 5. She writes the following program, where statement 5 is missing;
Integer i=0
Integer sum=0
while(i<=50) {
sum=sum+1
--MISSING STATEMENT 5—
}
Print sum
Which of the following options will you use for statement 5? Choose the correct answer
A. l=5              B. I=5*I              C. I=i+1              D. I=i+5

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

100. Every element of a data structure has an address and a key associated with it. A search mechanism deals eith teo or more values assigned to the same address y using the key. What is the search mechanism?

A. Linear search            B. Binary search             C. Hash coded search        D. None of these

101. Which will be the input to second pass? If the list before starting the Radix sort is: 729, 150, 123, 931, 348, and 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 102. Sorting is not possible by using which of the following methods? A. Insertion B. Selection C. Exchange D. Deletion Ans D 103. Srujan writes a sorting algorithm. The algorithm takes different of time to sort two different list of equal size. What is the possible difference between two lists? A. All numbers in one list are more than 100, while in the others are less than 100. B. The ordering of numbers with respect to magnitude in two list has has different properties. C. One list has all negative numbers, while others has all positive numbers. D. One list contains 0 as an element, while the other does not. 104. Srishti writes a program to find an element in array A[5] with following elements In order 8 30 40 45 70.she runs the program to find number x. x is found in first Iteration of binary search. What is value of x? A. 40 B. 8 C. 70 D. 30 105. Abhinav wants to find largest number in a given list of 20 numbers. Which of following is an efficient approach to do this? A. Use bubble sort to sort the list in ascending order and Then print first number of series B. Use selection sort to sort the list in descending order and Then printf first number of series C. Implement on iteration of selection sort for descending order and printf first number in series D. None of these. 106. Null function is also known as___________ A. Anonymous function B. Generic function C. void function D. Null operator Ans D 107. In breath first rule which of the following option is true? A. Beginning from a node, first all its adjacent nodes are traversed. B. Beginning from a node, each adjacent node is fully explored before traversing next adjacent node. C. Beginning from a node, nodes are traversed in cyclical order. D. None of these. Ans B 108. Which one of following is lowest level format to which computer converts a higher Language program before execution? A. English code B. Machine code C. Assembly language D. System language Ans B 109. Choose the correct answer. Consider the statement while (a < 10.0) { a = a*a } Assuming a is positive, for what value of a will this code statement result in an infinite loop? A. a < 1.0 B. a < sqrt (10) C. a > sqrt (10) D. a = 0 Solution: Answer will be Option A. Option 4 can’t be true as 0 is neither + ve, or –ve. 110. Choose the correct answer. Ankita takes as input 2 integer numbers, a and b, whose value can be between 0 and 31. He stores them as 5 bit numbers. He writes the following code to process these numbers to produce a third number c. c = 2*(a - b) In how many minimum bits should Ankita store c? A. 6 bits B. 7 bits C. 8 bits D. 9 bits Solution: Answer will be Option B. c = 2*(a - b) Lowest number will be generated when a=0 and b=31 c= 2*(0-31) = -64 Highest number will be generated when a=31 and b=0 c= 2*(31-0) = 64 range = -64 to 64 bits required = 7

Solution: Answer will be Option B.
c = 2*(a - b)
Lowest number will be generated when a=0 and b=31
c= 2*(0-31) = -64
Highest number will be generated when a=31 and b=0
c= 2*(31-0) = 64
range = -64 to 64
bits required = 7



111. Which of the following accessibility modes can be the specifier of a top level class?
1. Private                       2. Protected                     3. Public                              4. No modifier
A. only 3                       B. only 44                        C. Both 1 and 3                    D. Both 2 and 3                 E. Both 3 and 4
Solution: Answer will be Option A.
112. A language has 28 different letters in total. Each word in 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 assigns to the database to store all kind of word of language?
A. 7                                                     B. 35                                                   C. 28                                                   D. 196
Solution: Answer will be Option B.
To represent 28 different letters we need 5 bits per each (2^5=32). Each word contains max letters 7. Hence number of bits=5*7=35.
113. Recursive function is executed in a   ___________________________
A. Last in First Out Order                 B. First in First Out Order           C. Parallel Fashion            D. All of the above
Solution: Answer will be Option A.
114. Yukta created an interface to use it in different parts of the program by implementing it. But she forgot to specify the access specifier for each contained method. What will be the access specifier of the methods that will be inherited/implemented?
A. Public                                 B. Private                                    C. Protected                    D. An error will be generated
Solution: Answer will be Option A.
115. Which of the following statements are true?
1)An Arithmetic left shift multiplies a signed number by two
2)An Arithmetic right shift divides a signed number by two
3)Mask operation is an AND micro-operation and insert is an OR micro-operation
4)In a logical shift, the serial input to the shift is one
A. Both 1 and 2                      B. Both 3 and 4                                       C. 1, 2 and 3                                     D. 2, 3 and 4
Solution: Answer will be Option C.
116. Choose the correct answer. A Queue is implemented by a linear array of size 10 (and not as a circularly connected array). Front and Rear are represented as an index in the array. To add an element, the rear index is incremented and the element is added. To delete an element, the front index is incremented. The following operations are done on an empty queue.
ADD 1; DELETE; ADD 2; ADD 3; ADD 4; DELETE, DELETE.
After this set of operations, what is the maximum capacity of the queue?
A. 6                                 B. 7                                  C. 10                               D. None of these

Solution: Answer will be option B.
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 = 0
ADD 3 Front = 0 ,Rear = 1
ADD 4 Front = 0 ,Rear = 2
DELETE Front = 1 ,Rear = 2
DELETE Front = 2 ,Rear = 2
Now 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.
117. 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
Solution: Answer will be option A. 1 + 4 + 16 + 64 + 256
118. A 8-bit signed integer has the following range?
A. 0 to 255                           B. -128 to 127                  C. -255 to 254                              D. 0 to 509
Solution: Answer will be option B.

119. What will be the output of the following code statements?
integer x = 34. 54, y = 20, z =
print ( y > 50 AND z > 10 or x > 30 )
A. 0                        B. 1                      C. -1                    D. 10
Solution: Answer will be option B.

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


121. I have a problem to solve which takes as input a number n property that given the solution for (n
programming technique will I use to solve such a problem?
A. Iteration         B. Decision-making       C. Object Oriented Programming   D. Recursion
Solution: Answer will be option B.

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

123. 123. 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
Solution: Answer will be option D.

124. One of the following options is a form of access used to add and remove nodes from a queue.
A. LIFO               B. FIFO               C. Both LIFO and FIFO    D. None of these
Solution: Answer will be option C.


125. What is the time complexity of adding three matrices of size NXN cell-by-cell?
A. O (N)                                B. O (N^2)                           C. O (N^3)                           D. None of these
Solution: Answer will be option B.
126. Choose the correct answer. A sort which uses the binary tree concept such that any number in the tree is larger than all the numbers in the sub tree  below it is called
A. Selection sort                                            B. Insertion sort                                                C. Heap sort                       D. Quick sort
Solution: Answer will be option C.



Related Pages:

No comments:

Post a Comment