You are on page 1of 6

C &DS Questions

1. Which one of the following cannot be made as virtual?


A. Destructor
B. Member function
C. Constructor
D. None of these
2. What is functionality of seekp function?
A. return current location of read marker
B. move read marker to given position
C. return current location of write marker
D. move write marker to given position
3.If Z is the name of the class, what is the correct way to declare copy constructor of
Z?
A. Z(Z arg)
B. Z(Z* arg)
C. Z(const Z* arg)
D. Z(const Z& arg)
4. How "Late binding" is implemented in C++?
A. Using C++ tables
B. Using virtual tables
C. Using indexed virtual tables
D. Using polymorphic tables
5. Assume a class TEST. Which of the following invoke copy constructor?
A. TEST T2(T1)
B. TEST T4=T1
C. T2=T1
D. Both A and B
6. Using friend operator function, following perfect set of operators may not be
overloaded?
A. =,(),[], ->
B. <<,==,[],>>
C.?,=,(),++
D. None of the above
7. Which of the following is correct about the statements given below?
I. All operators can be overloaded in C++
II. We can change the precedence rules of an operator in C++
A. Only I is true
B. Both I and II are false
C. Only II is true
D. Both I and II are true
8. In multipath inheritance, in order to remove duplicate set of records in child class
we,
A. Write virtual function in parent classes
B. Write virtual function in base class
C. Make base class as virtual base class
D. All of the above
9. Which one of the following is the correct way to declare a pure virtual function?
A. virtual void Display(void){0};
B. virtual void Display = 0;
C. virtual void Display(void) = 0;
D. void Display(void) = 0;
10. Which of the following is false for cout?
A. It represents standard output
B. It is an object of ostream class
C. It is a class of which stream is an object
D. Using cout the data can be written to the user’s terminal.
11. In which case is it mandatory to provide a destructor in a class?
A. Almost in every class
B. Class for which two or more than two objects will be created
C. Class for which copy constructor is defined
D. Class whose objects will be created dynamically
12. Which one of the following is true about friend function?
A. It is a non-member function which has privilege to access private
members of a class
B. It is a public member function of a class
C. It is a private member function of a class
D. It is a member function which has privilege to access private members
of a class
13. Which one of the following properties is true for a non-static member function?
A. It has access to static as well as non-static the members of its class
B. It has access to only other static members of its class
C. It can be called with only class name, not with objects
D. It can access only non-static members of its class
14. Paying attention to the important properties while ignoring inessential details is
known as________:
A. Selectiveness
B. Polymorphism
C. Abstraction
D. Summarizing
15. Which of the below statement is correct regarding a member function of a class
which is a const member function?
A. No local variables can be created inside this function
B. The function cannot modify the state of the data members of the object
through which it is called
C. The function can access only static data members
D. The function can call non constant member functions of the class
16. What is deep copy?
A. Deep copy creates a copy of the dynamically allocated objects too.
B. A deep copy just copies the values of the data as they are.
C. A deep copy creates a copy of the statically allocated objects too
D. Both b and c above
17. Consider the following program segment
Int b = 20;
void main()
{ int b = 10;
cout <<::b << b;
}
The output of this program is
A. Syntax error
B. 10 20
C. 20 10
D. 20 20
18. What does the following declaration mean?
int *ptr[20]; ?
A. ptr is an array of 20 integer pointers
B. ptr is a pointer to an array of 20 integers
C. ptr is an array of 20 integers
D. ptr is a pointer to an array
19. Which of the following correctly applies to C++ struct?
A. Programmer can implement inheritance through C++ struct
B. C++ struct defaults to private access specifier
C. C++ struct has no member functions
D. Both A and C
20. Which one of the following is not a feature of C++??
A. Abstraction
B. Encapsulation
C. Garbage Collection
D. Polymorphism
21. The inorder traversal of tree will yield a sorted listing of elements of tree in
A. Binary trees
B. Binary search trees
C. Heaps
D. None of above
22. Consider that N elements are to be sorted. What is the worst case time
complexity of Bubble Sort?
A. O(1)
B. O(log 2N)
C. O(N)
D. O(N2)
23. In a Max-heap, element with the greatest key is always in the ______________
node
A. leaf
B. root
C. first node of left sub tree
D. first node of right sub tree
24. The two measures of efficiency of an algorithm are
A. Processor and Memory
B. Complexity and Capacity
C. Time and Space
D. Data and Space
25. Depth First Search graph traversal method makes use of _________ data structure.
A. Stack
B. Queue
C. Linked List
D. Tree
26. Complexity of merge sort algorithm is
A. O(N)
B. O(log N)
C. O(N2)
D. O(N log N)
27. In case of Binary Tree which of the following traversal method gives sorted
output?
A. Preorder
B. Postorder
C. Inorder
D. None of these
28. In a sorted singly linked list with N nodes, the time taken to insert an element in
appropriate place is
A. O (1)
B. O (log N)
C. O (N)
D. O (N 1og N)
29. The number of swapping needed to sort the numbers 8, 22, 7, 9, 31, 19, 5, 13 in
ascending order, using bubble sort is
A. 11
B. 12
C. 13
D. 14
30. Which of the following sorting algorithms does not have a worst case time
complexity of O(N2)
A. Insertion sort
B. Merge sort
C. Quick sort
D. Bubble sort
31. A data structure where elements can be added or removed at either end but not
in the middle
A. Linked lists
B. Stacks
C. Queues
D. Deque (Double Ended Queue)
32. Which of the following are true about divide and conquer algorithms?
A. Divide and conquer algorithm design paradigm is based on multi-branched
recursion.
B. A divides and conquer algorithm works by recursively breaking down a
problem into two or more sub-problems of the same type.
C. Quick sort and merge sort use divide and conquer.
D. All of the above
33. in polynomial manipulation, nodes consists of three field representing
A. Coefficient, exponential and link
B. Previous item link, data item, next item link
C. Coefficient, data item and link
D. None of the above
34. If you began with an empty AVL tree, and then inserted the following keys into the
tree in the following order:
20, 40, 15, 25, 30, 80, 75, 95, 35, 90
Which key would be in the root of the tree after inserting all the keys?
A. 75
B .40
C. 35
D. 30
35. How many singly linked lists are used to represent a graph with n nodes and m
edges, when using an edge list representation?
A. m
B. n
C. m + n
D. m*n
36. The time complexity of a right skewed binary search tree with n elements is
A. O(n)
B. Equal to the time complexity in searching an element linearly in a list of n
elements
C. Worst case complexity for a binary search tree
D. All of the above
37. Suppose you have a directed graph representing all the flights that an airline flies.
What algorithm might be used to find the best sequence of connections from one
city to another?
A. Breadth first search.
B. Depth first search.
C. A cycle-finding algorithm.
D. A shortest-path algorithm
38. The searching technique that takes O (1) time to find a data is
A. Linear Search
B. Binary Search
C. Hashing
D. Tree Search
39. A mathematical-model with a collection of operations defined on that model is called
A. Data structure
B. Abstract Data Type
C. Primitive Data Type
D. Algorithm
40. A full binary tree with n non-leaf nodes contains
A. log N nodes
B. N + 1 nodes
C. 2N – 1 nodes
D. 2N + 1 nodes

You might also like