Tuesday, August 25, 2015

AMCAT COMPUTER PROGRAMMMING PREVIOUS QUESTIONS (PAPERS)-5

2015 & 2016 Batch Freshers Registration Link

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

Ans B

Contact Form

Name

Email *

Message *