DAC - EANDC - QB - Question Bank For ADS
DAC - EANDC - QB - Question Bank For ADS
1. A is a special member function used to initialize the data members of a class. (constructor)
2. The default access for members of a class is . (private)
3. Member functions of a class are normally made and data members of a class are normally
made . (public, private)
4. Inheritance enables which saves time in development , and encourages using previously
proven and high quality software. (reusability)
5. The three member accessspecifiers are , and . (public, private,
protected)
6. A “has a” relationship between classes represents and an “is a” relationship between
classes represent . (containment, inheritance)
7. A pure virtual function is specified by placing at the end of its prototype in the class
definition. (=0;)
8. A operator is called as de-referencing operator. (*)
9. The size of a class with no data members and member functions is bytes. (1)
10. A class is called as abstract base class if it has a function. (pure virtual)
11. A queue is list. (linear)
12. A is a function that invokes itself. (Recursion)
13. A is a set of instance or values. (object)
14. A is a linear list in which additions and deletions take place ate the same end. (stack)
15. A is a linear list in which additions and deletions take place at different ends. (queue)
16. A variable definition defines a of the variable and reserves for it. (instance,
memory)
17. Literals are always . (constants)
18. Name mangling is doneby the . (C++ compiler)
19. Pointers are that contain the addresses of other variables and . (variables,
functions)
20. A program can use the address of any variable in an expression, except variables declared with the
storage class. (register)
21. One cannot perform pointer arithmetic on a pointer without . (void , cast)
22. new operator allocates memory blocks from the . (Heap)
23. The new operator throws a when heap is exhausted. (runtime exception)
24. The constructor and destructor of a class are called . (automatically)
25. Two or more functions may have the same name, as long as their are different. (parameter
lists).
26. A constructor with default arguments for all its parameters is called a constructor. (default)
Page 1 of 2
27. Static member functions can access only the data members of a class. (Static)
28. The two types of polymorphism is : & . (Run time and compile time.)
29. A file stream is an extensionof a stream. (console)
30. The Standard Template Library(STL) is a library of templates.(container class)
31. Run time polymorphism is than the compile time polymorphism.
32. With private inheritance, public and protected members of the base class become members of
the derived class. (private)
33. A tree node with no children is called a node. (leaf)
34. The shape of a binary tree if determined by the order in which values are inserted. (True)
35. In inorder traversal, the node’s data is processed first, then the left and right nodes are visited. (True)
36. The STL stack container is an adapter for the , , and STL containers.
(vectors, lists, deques)
37. A data structure that point to an object of the same type, as itself is known as a data
structure. (self-refrential)
38. After creating a linked list’s head pointer, one should make sure it points to before using it in
any operations.(NULL)
39. a node means adding it to a list, but not necessarily to theend. (inserting)
40. In a list, the last node has a pointer to the first node. (circular).
41. The block contains code that directly or indirectly might cause an exception to be thrown.
(try)
42. When writing function or class template, one use a to specify a generic data type. (type-
parameter)
43. A template works with a specific data type. (specialized)
44. A container uses keys to rapidly access elements. (associative)
45. are pointer-like objects used to access information stored in a container.(Iterators)
46. In some cases the class must be declared(not defined ) before a reference is made to it. This is known
as . (forward declaration).
47. are blue prints of a function that can be applied to different data types. (templates)
48. and are two error objects. (clog, cerr)
49. We can convert a class data type to basic data type using . (member conversion function)
Page 2 of 2
15. A class encapsulates the implementation and interface of a user-defined data type and constitutes an
abstract data type. (True)
16. std::cout is a standard input stream. (True)
17. Preprocessor #define macro and inline functions use the same mechanism. (False)
18. The ‘break’ keyword is only used in the switch..case statement. (False)
19. The new operator returns the address and size of the memory block that it allocates. (False)
20. The heap storage is used for local objects. (False)
21. A call to a function that returns a reference can appear on either side of an assignment. (True).
22. It is not necessary to initialize a reference to real object when it is declared.(False)
23. There can be a null reference. (False)
24. One can change the value of a reference after it is initialized. (False)
25. It is nothing wrong that a function returning a reference to an automatic variable. (False)
26. One can apply pointer arithmetic with reference variables. (False)
27. The preprocessor processes source code before the compiler does. (True)
28. A class is a basic unit of object-oriented programming. (False)
29. A function template defines a parameterized nonmember function, which enables a program to call the
same function with different types of arguments. (True)
30. Destructors can be overloaded. (False)
31. Static data members cannot be private. (False)
32. Static member functions can use this pointer. (False)
33. One cannot use enumerations in a class. (False)
34. One cannot create an object of a virtual class. (False)
35. The push operation inserts an element at the end of a stack. (False)
36. It is not necessary for each node in a linked list to have a self-referential pointer. (False)
37. In physical memory, the nodes in a linked list may be scattered around. (True)
38. When the head pointer points to NULL, it signifies an empty list. (True)
39. Linked list are not superior to STL vectors. (False)
40. Deleting a node in a linked list is a simple matter of using the delete operator to free the node’s
memory. (False)
41. A class that builds a linked list should destroy the list in the class destructor. (True)
42. Once an exception has been throwe, it is not possible for the program to jump back to the throw point.
(True)
43. It is not possible to rethrow an exception. (False)
44. There can be only one catch block in a program.(False)
45. When an exception if throw, but not caught, the program ignorers the error. (False)
46. A class object passed to a function template must overload any operators used on the class object by
the template. (True)
47. In the function template definition it is not necessary to use each type parameter declared in the
template prefix. (False)
Page 3 of 2
48. It is possible to overload a function template and an ordinary (non-template) function. (True)
49. A class template may not be used as a base class. (False)
50. When declaring an iterator from the STL, the compiler automatically creates the right kind, depending
upon the container it is used with. (True)
51. ‘ios’ stream is derived from iostream. (False)
52. ‘eof()’ function returns zero value if the eofbit is set. (False)
7. 6.5 is a constant.
(a) string literal (b) float literal (c) double literal (d) character literal
10. Each generic type in a template function definition is preceded by the keyword .
(a) class (b) type (c) function (d) template
11. To delete a dynamically allocated array named ‘a’, the correct statement is
(a) delete a; (b) delete a[0]; (c) delete []a; (d) delete [0]a;
16. The design of classes in a way that hides the details of implementation from the user is known as:
(a) Encapsulation (b) Information Hiding
(c) Data abstraction (d) All of the above
Page 5 of 12
17. Which of the following keywords do you think can be used when declaring static members in a class?
(i) Public
(ii) Private
(iii) Protected
18. I want a nonmember function to have access to the private members of a class. The class must declare
that function:
(a) friend (b) inline
(c) static (d) virtual
19. The ability to reuse objects already defined, perhaps for a different purpose, with modification
appropriate to the new purpose, is referred to as
(a) Information hiding. (b) Inheritance.
(c) Redefinition. (d) Overloading.
20. What do you think is the outcome of calling a redefined non-virtual function using a base-class
pointer?
(a) The appropriate redefined version of the function will be used.
(b) The base-class version of the function will always be used.
(c) The outcome is unpredictable.
(d) A run-time error will occur.
21. A class member that is to be shared among all objects of a class is called
(a) A const member (b) A reference parameter
(c) A static member (d) A function member
Page 6 of 12
25. In protected inheritance:
(a) The public members of the base class become public.
(b) The public members of the base class become protected.
(c) The protected members of the base class become private.
(d) The public members of the base class become inaccessible.
Page 7 of 12
33. Which is not a data structure:
(a) Array (b) Linked List
(c) Binary (d) Struct
38. If a tree has only one node than the tree may be a:
(a) Binary tree (b) Tertiary tree
(c) Not a tree (d) (a) & (b)
44. A Graph is a :
(a) Linear Data Structure
Page 8 of 12
(b) Non- Linear Data Structure
(c) Not a Data Structure
(d) Circular Data Structure
46. The organization and management of data structures are take place in:
(a) Primary Memory
(b) Secondary Memory
(c) External Memory
(d) Primary & Secondary Memory
47. The node of the circular doubly linked list must have:
(a) One data and two address fields
(b) One data and one address fields
(c) Two data and two address fields
(d) Two data and one address fields
49. In an expression binary tree, to obtain the postfix form of the expression we traverse in:
(a) Pre order (b) Post order
(c) In order (d) Pre and Post order both
50. In a binary tree, to delete a node that has two children, we require:
(a) Post order successor
(b) Pre order successor
(c) In order ancestor
(d) In order successor
51. What is the max number of edges an undirected graph with N nodes can have?
(a) N (b) N^2
(c) 2N (d) none of the above
Page 9 of 12
53. One of the following algorithms is NOT an example of using the divide-and-conquer technique. Which
one?
(a) quicksort (b) mergesort
(c) bubblesort (d) binary search
54. To apply the binary search algorithm, the data items should be represented as:
(a) a binary tree (b) a list implemented as a linked-list
(c) a list implemented asan array (d) an ordered list implemented as an array
56. 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.
57. What kind of list is best to answer questions such as "What is the item at position n?"
(a) Lists implemented with an array.
(b) Doubly-linked lists.
(c) Singly-linked lists.
(d) Doubly-linked or singly-linked lists are equally best
58. The operation for adding an entry to a stack is traditionally called:
(a) add (b) append
(c) insert (d) push
59. A performs the copying for value returns as well as for value parameters.
(a) Copy Constructor (b) Parameterize Constructor
(c) Default Constructor (d) none
89. Consider A and B as two operands, and “+” as the operator, the presentation A + B is called:
(a) prefix (b) postfix
(c) infix (d) suffix
Page 10 of 12
Answers the followings:
1. Write three main differences between inline functions and macros with parameters.
2. What are the differences between pointers and references?
3. What is there is no null reference?
4. Why we use operator overloading?
5. What is an automatic default constructor, and what does it do?
6. When is it appropriate to use a const reference parameter? Give a small example as part of your
answer?
7. What are the differences between variable declaration and variable definition?
8. What is the significance of wchar_t keyword?
9. Differences between new operator and malloc function.
Page 11 of 12
10. What are constant member functions?
11. In what situations a copy constructor is invoked.
12. What is initializer list?
13. What are template classes?
14. What are the operators that cannot be overloaded?
15. What are constant member functions?
16. When do you need deep copying?
17. Are templates memory efficient and why?
18. What is a conversion constructor?
19. What is the significant of this keyword?
20. When you use static data members. Given an example.
21. What is the use of mutable data members?
22. What are the smart pointers?
23. What is the difference between multiple inheritance and multilevel inheritance?
24. What is the difference between overloading and overriding?
25. What is the significant of ‘vptr’ in virtual functions.
26. Write five examples for STL sequence containers.
27. What do you mean by dangling pointer.
28. Write the steps to delete a node with two children in binary search tree.
29. What are iterators?
30. What are namespaces? What is the advantage of having a namespace? Givesuitable examples
31. Why static member functions do not receive ‘this’ pointer?
32. What do you mean by abstraction?
33. What do you mean by encapsulation?
34. What are template classes?
35. Write the syntax for defining a function outside the class.
36. Write a operator + of the string class which append two strings. The string is stored within the class as
data, which is char[50].
37. What is binding? Describe static and run time binding.
38. Write a function template that takes five parameters and returns the maximum of them. Also it is to be
initialized using int and float.
39. Why do we need virtual destructors?
40. It is legal to return local variables from a function which returns by reference. State true/ false with
justification.
41. Write a code to initialize the pointer to a data member of a class.
42. Static member functions do not receive ‘this’ pointer. State true/ false with justification.
Page 12 of 12