## Tuesday, August 25, 2015

### AMCAT COMPUTER PROGRAMMMING PREVIOUS QUESTIONS (PAPERS)-4

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