You are on page 1of 51

CONTENTS

Topic ONE: SOFTWARE ENGINEERING PRINCIPLES AND C++ CLASSES.............................2


Topic TWO: STANDARD TEMPLATE LIBRARY (STL)....................................................................14
Topic THREE: LINKED LISTS.............................................................................................................22
Topic FOUR: RECURSION...................................................................................................................47
Topic FIVE: STACKS.............................................................................................................................47
Topic SIX: QUEUES..............................................................................................................................48
Topic SEVEN: SEARCHING AND HASHING ALGORITHMS........................................................48
Topic EIGHT: SORTING ALGORITHMS............................................................................................48
Topic NINE: BINARY TREES AND B-TREES....................................................................................48

SEMESTER 4 1 PROGRAMMING 622 (C++)


Topic ONE: SOFTWARE ENGINEERING
PRINCIPLES AND C++ CLASSES
1. Coupling and cohesion can be represented using a
a. Structure chart
b. dependence matrix
c. SRS
d. cause-effect graph

Answer: dependence matrix

2. The level at which the software uses scarce resources is


a. all of the option mentioned
b. portability
c. efficiency
d. reliability

Answer: efficiency

3. For a well understood data processing application it is best to use


a. The waterfall model
b. prototyping model
c. the evolutionary model
d. the spiral model

Answer: The waterfall model

4. All activities lying on critical path have slack time equal to


a. None of the option mentioned
b. 1
c. 0
d. 2

Answer: 0

5. Modules X and Y operate on the same input and output data, then the cohesion is
a. Sequential
b. Procedural

SEMESTER 4 2 PROGRAMMING 622 (C++)


c. Communicational
d. Logical

Answer: Communicational

6. Identify the time, space complexity of this syntax

dbl k = 0;

for (t = 0; t < B; t++) {

for (s = B; s > t; s--) {

k = k + t + s;

}
a. O(B* Sqrt(B))
b. O(B*log(B))
c. O(B)
d. O(B*B)

Answer: O(B*B)

7. ER model shows the


a. All of the option mentioned
b. Static view.
c. Functional view.
d. Dynamic view.

Answer: Static view.

8. In unified modified language, the diagrams used in assessing class diagrams for precision
tendencies are called …………
a. Deployment diagrams
b. Object diagrams
c. Component diagrams
d. Package diagrams

SEMESTER 4 3 PROGRAMMING 622 (C++)


Answer: Object diagrams

9. What is the purpose of malloc in a linked list in programming?


a. used to allocate a block of memory on the heap
b. used to create a list
c. used to create a data structure
d. used as a pre-processor condition for a liked list

Answer: used to allocate a block of memory on the heap

10. In the spiral model ‘risk analysis’ is performed


a. In every loop
b. before using spiral model
c. In the first loop
d. in the first and second loop

Answer: In every loop

11. IEEE 830-1993 is a IEEE recommended standard for


a. Software requirement specification and Software design.
b. Testing.
c. Software requirement specification.
d. Software design.

Answer: Software requirement specification.

12. In Unified Modelling language, the diagram which captures the system static structure and
provide foundation for other models is called ……………
a. Deployment diagrams
b. Component diagrams
c. Object diagrams
d. Class diagrams

Answer: Class diagrams

13. Aggregation represents


a. part_of relationship

SEMESTER 4 4 PROGRAMMING 622 (C++)


b. composed_of relationship
c. is_a relationship
d. none of the option mentioned

Answer: composed_of relationship

14. Each time a defect gets detected and fixed, the reliability of a software product
a. remains constant.
b. cannot say anything.
c. decreases.
d. increases.

Answer: increases.

15. If P is risk probability, L is loss, then Risk Exposure (RE) is computed as


a. RE = P + L
b. RE = P*L
c. RE = P/L
d. RE = 2* P *L

Answer: RE = P*L

16. The worst type of coupling is


a. stamp coupling.
b. content coupling.
c. Data coupling.
d. control coupling.

Answer: content coupling.

17. For a function z the linked list return 1 if and only if

struct node

int ele ;

SEMESTER 4 5 PROGRAMMING 622 (C++)


struct node * next;

};

int f (struct node *z)

return((z==NULL) ||((z->next==NULL)||(z->ele<=z->next->ele) && (z->next)));

}
a. the elements are sorted in non-descending order
b. the list has zero elements
c. the elements are sorted in non-ascending order
d. the elements are not sorted in any order

Answer: the elements are sorted in non-descending order

18. The code snippet below is used to …….

if(head==NULL)

head=tmp;

tail=tmp;

}
a. to insert elements into the list
b. to create a linked list
c. to create a node o
d. to check if the linked list is empty or not

Answer: to check if the linked list is empty or not

19. Structured charts are a product of


a. design
b. requirements gathering

SEMESTER 4 6 PROGRAMMING 622 (C++)


c. coding
d. requirements analysis

Answer: design

20. Modifying the software to match changes in the ever changing environment is called
a. adaptive maintenance
b. perfective maintenance
c. corrective maintenance
d. preventive maintenance

Answer: adaptive maintenance

21. Which class can have member functions without their implementation?
a. Abstract class
b. Default class
c. String class
d. Template class

Answer: Abstract class

22. The model that assumes that effort and development time are functions of product size
alone is
a. Intermediate COCOMO model
b. Detailed COCOMO model
c. All the three COCOMO models
d. Basic COCOMO model

Answer: Basic COCOMO model

23. If every requirement can be checked by a cost-effective process, then the SRS is
a. modifiable
b. complete
c. verifiable
d. traceable

Answer: verifiable

SEMESTER 4 7 PROGRAMMING 622 (C++)


24. Number of clauses used in ISO 9001 to specify quality system requirements are:
a. 20
b. 15
c. 28
d. 25

Answer: 20

25. Complexity hiding is called ………….


a. Abstraction
b. Encapsulation
c. Data hiding
d. Composition

Answer: Encapsulation

26. One of the fault base testing techniques is


a. unit testing.
b. Stress testing.
c. beta testing.
d. mutation testing.

Answer: mutation testing.

27. The desired level of coupling is


a. No coupling
b. Control coupling
c. Data coupling
d. Common coupling

Answer: Data coupling

28. The feature of the object oriented paradigm which helps code reuse is
a. class.
b. inheritance.
c. object.
d. aggregation.

SEMESTER 4 8 PROGRAMMING 622 (C++)


Answer: inheritance.

29. Changes made to an information system to add the desired but not necessarily the
required features is called
a. Adaptive maintenance.
b. Perfective maintenance.
c. Preventative maintenance.
d. Corrective maintenance.

Answer: Perfective maintenance.

30. SRS is also known as specification of


a. Stress testing
b. Black box testing
c. White box testing
d. Integrated testing

Answer: Black box testing

31. Changes made to the system to reduce the future system failure chances is called
a. Corrective Maintenance
b. Perfective Maintenance
c. Preventive Maintenance
d. Adaptive Maintenance

Answer: Preventive Maintenance

32. A COCOMO model is


a. Comprehensive Cost Estimation Model.
b. Constructive Cost Estimation Model.
c. Common Cost Estimation Model.
d. Complete Cost Estimation Model.

Answer: Constructive Cost Estimation Model.

33. When traversing a doubly linked list, how can traversal be performed?
a. In upwards direction
b. In forward direction only
c. both backward and forward direction

SEMESTER 4 9 PROGRAMMING 622 (C++)


d. In backwards direction only

Answer: both backward and forward direction

34. An object encapsulates


a. Data
b. Behaviour
c. Data and behaviour
d. State

Answer: Data and behaviour

35. The tools that support different stages of software development life cycle are called:
a. CASE Tools
b. CAME tools
c. CAQE tools
d. CARE tools

Answer: CASE Tools

36. The model in which the requirements are implemented by category is


a. Waterfall Model
b. Evolutionary Development Model
c. Iterative Enhancement Model
d. Prototyping

Answer: Evolutionary Development Model

37. Requirements can be refined using


a. The waterfall model
b. the evolutionary model
c. the spiral model
d. prototyping model

Answer: prototyping model

38. If every requirement stated in the Software Requirement Specification (SRS) has only one
interpretation, SRS is said to be

SEMESTER 4 10 PROGRAMMING 622 (C++)


a. consistent.
b. unambiguous.
c. correct.
d. verifiable.

Answer: unambiguous.

39. The problem that threatens the success of a project but which has not yet happened is a
a. error
b. failure
c. bug
d. risk

Answer: risk

40. Protection of member function and data member in a class is done by ……………….
a. Using Inheritance
b. Using Access specifiers
c. Using Abstraction
d. Using encapsulation

Answer: Using Access specifiers

41. A fault simulation testing technique is


a. Mutation testing
b. Stress testing
c. Black box testing
d. White box testing

Answer: Mutation testing

42. If the objects focus on the problem domain, then we are concerned with
a. Object Oriented Analysis &amp; Design
b. None of the option mentioned
c. Object Oriented Analysis.
d. Object Oriented Design

Answer: Object Oriented Analysis.

SEMESTER 4 11 PROGRAMMING 622 (C++)


43. Output comparators are used in
a. dynamic testing of single and multiple module
b. static testing of single module
c. static testing of single and multiple module
d. dynamic testing of single module

Answer: dynamic testing of single and multiple module

44. Which of the following statements is true


a. Abstract data types are the same as classes
b. Classes cannot inherit from the same base class
c. Object have state and behavior
d. Abstract data types do not allow inheritance

Answer: Abstract data types do not allow inheritance

45. The most important feature of spiral model is


a. configuration management.
b. requirement analysis.
c. quality management.
d. risk management.

Answer: risk management.

46. Identify the time, space complexity of this snippet below

dbl k = 0, l = 0;

for (i = 0; i < T; i++) {

k = k + richfield();

for (j = 0; j < S; j++) {

l = l + richfield();

SEMESTER 4 12 PROGRAMMING 622 (C++)


}
a. O(T +S) time, O(1) space
b. O(T* S) time, O(T + S) space
c. O(T + S) time, O(T + S) space
d. O(N * S) time, O(1) space

Answer: O(T +S) time, O(1) space

47. SRD stands for


a. Structured requirements definition
b. Software requirements definition
c. Structured requirements diagram
d. Software requirements diagram

Answer: Structured requirements definition

48. In OOPs model such as C++ which among the option below reveals only important
information to users?
a. Encapsulation
b. Abstraction
c. Data hiding
d. Hiding complexity

Answer: Abstraction

49. The following C++ code snippet takes a singly- linked list of characters as a parameter and
reposition the elements in the lists. The function contains the characters A, B,C,D,E,F,G in
the given order. What will be the positions of the characters after the program compiles.

struct node

{
char data;
struct node* next;
};
void reposition (struct node* list)
{
struct node *x,y;
data temp;

SEMESTER 4 13 PROGRAMMING 622 (C++)


if (! List || ! list->next) return;
x->list;

y=list->next;
while(y)
{
temp=x->data;

x->data=y->data;
y->value=temp;

x=y->next;
y=x?x->next:0;
}
}
a. B, A, D, C, F, E, G
b. G, F ,E ,D ,C ,B ,A
c. C, D, A, E ,B ,F ,G
d. F, G ,E ,D ,A ,B ,C

Answer: B, A, D, C, F, E, G

50. Alpha and Beta Testing are forms of


a. System Testing
b. Acceptance testing
c. Integration testing
d. Unit testing

Answer: Acceptance testing

51. In function point analysis, number of general system characteristics used to rate the
system are
a. 14
b. 10
c. 20
d. 12

Answer: 14

SEMESTER 4 14 PROGRAMMING 622 (C++)


52. All the modules of the system are integrated and tested as complete system in the case of
a. Sandwich testing
b. Bottom up testing
c. Top-down testing
d. Big-Bang testing

Answer: Big-Bang testing

Topic TWO: STANDARD TEMPLATE


LIBRARY (STL)
53. What will be the output of the function below?

int perform_a_recursive_func (int x, int y)

If (y==1)

return x;

else

return x + perform_a_recursive_func(x x-1);

perform_a_recursive_func(2,3);
a. 5
b. 4
c. 7
d. 3

Answer: 3

54. How many sets of requirements are need in designing a container?


a. 4
b. 1

SEMESTER 4 15 PROGRAMMING 622 (C++)


c. 2
d. 3

Answer: 3

55. What happens when the code snippet is executed?

void some_recursive_function();

some_recursive_function();

int main()

some_Recursive_function();

return 0;

}
a. It will give a runtime error
b. The code will be executed but it won’t show anything on the compiler afterwards
c. It will generate a random outcome
d. The code will run and afterwards it will stop because of a stack overflow

Answer: The code will run and afterwards it will stop because of a stack overflow

56. Which of the following is similar to recursion?


a. else elif statement
b. factorial
c. loop
d. if /else statement

Answer: loop

SEMESTER 4 16 PROGRAMMING 622 (C++)


57. Which container provides random access iterators?
a. vector and deque
b. vector
c. sort
d. deque

Answer: vector and deque

58. What is the defualt type oof linkage that are available for identifires?
a. none of the option mentioned
b. internal
c. external
d. no linkage

Answer: external

59. What are the Sequence Containers?


a. Containers that implements sorted data structures for fast search in O(logn)
b. Containers that implements unsorted(hashed) data structures for quick search in O(1)
c. Containers that implements data structures which can be accessed sequentially
d. Containers that implements data structures which can be accessed non-sequentially

Answer: Containers that implements data structures which can be accessed sequentially

60. To use internal linkage we have to use which keyword?


a. static
b. none of the option mentioned
c. extern
d. static or extern

Answer: static

61. What is the use of no linkage?


a. make the entity visible only to that block
b. make the entity visible to other programs
c. none of the option mentioned
d. make the entity visible to other blocks in the same program.

SEMESTER 4 17 PROGRAMMING 622 (C++)


Answer: make the entity visible only to that block

62. Which of the following type does the container should define?
a. Vector type
b. Storage type
c. None of the option mentioned
d. Iterator type

Answer: Iterator type

63. How the member functions in the container can be accessed?


a. Indirect
b. Iterator and Indirect
c. None of the option mentioned
d. Iterator

Answer: Iterator

64. What will be the output of the program below?

#include <iostream>

using namespace std;

int GCD (int x, int x)

if(n == 0) return m;

cout << "gcd(" << m << ',' << n <<')'<< endl;

return gcd(n, m % n);

int main()

SEMESTER 4 18 PROGRAMMING 622 (C++)


{

cout << "gcd = " << gcd(12, 4) << endl;

return 0;

}
a. 3
b. None of the options
c. 4
d. 24

Answer: None of the options

65. How any types of linkage are there in c++?


a. 2
b. 3
c. 4
d. 1

Answer: 3

66. Which one is used to refer to program elements in any translation units?
a. no linkage
b. none of the option mentioned
c. external linkage
d. internal linkage

Answer: external linkage

67. What will be the output of the following C++ code?

#include <iostream>

using namespace std;

void square (int *x, int *y)

SEMESTER 4 19 PROGRAMMING 622 (C++)


{

*x = (*x) * --(*y);

int main ( )

int number = 30;

square(&number, &number);

cout << number;

return 0;

}
a. 30
b. 9
c. 920
d. 870

Answer: 870

68. What will be the output of these two programs?


1. #ifndef Exercise_H
2. #define Exercise_H
3. int num = 842;
4. #endif
____________________________
1. #include <iostream>
2. #include "exe.h"
3. using namespace std;
4. int main(int argc, char * argv[] )
5. {
6. cout << number++;
7. return 0;

SEMESTER 4 20 PROGRAMMING 622 (C++)


8. }
a. 842
b. 843
c. compile time error
d. none of the mentioned

Answer: 842

69. Which is used to return the number of characters in the string?


a. None of the option mentioned
b. length
c. size
d. length and size

Answer: length and size

70. Which is used for manually writing lookup table?


a. std:map
b. std:lookup
c. None of the otpion mentioned
d. std:find

Answer: std:map

71. Which interface in the container is required for storage management?


a. Memory management
b. None of the mentioned
c. Allocater interface
d. Memory interface

Answer: Allocater interface

72. Which are the parameters for the content of the buffer?
a. Two of these sections
b. closed
c. finish
d. start

Answer: Two of these sections

SEMESTER 4 21 PROGRAMMING 622 (C++)


73. How many types of representation are in string?
a. 2
b. 4
c. 3
d. 1

Answer: 2

74. Which header file is used for Iterators?


a. &lt;iterator&gt;
b. &lt;iter&gt;
c. &lt;algorithm&gt;
d. &lt;loopIter&gt;

Answer: &lt;iterator&gt;

75. Give the output of the following program?

int a=23;

cout<<++a;

cout<<a;
a. 24 , 23
b. 23 , 24
c. 24 , 24
d. 23 , 23

Answer: 24 , 24

76. A function that calls itself during execution is called ………….


a. Executor
b. Iteration
c. Recursion
d. Repetitive

Answer: Recursion

SEMESTER 4 22 PROGRAMMING 622 (C++)


77. To use external linkage we have to use which keyword?
a. none of the option mentioned
b. static
c. extern
d. const

Answer: extern

78. Which is present in the basic interface of the allocator interface?


a. Set of typedefs
b. A pair of allocation functions
c. allocate()
d. All of the option mentioned

Answer: All of the option mentioned

79. Which is used to use a function from one source file to another?
a. prototype
b. none of the option mentioned
c. code
d. declaration

Answer: prototype

80. What is the header file for the string class?


a. None of the option mentioned
b. #include<ios>
c. #include<string>
d. #include<str>

Answer: #include<string>

Topic THREE: LINKED LISTS


81. Observe following program and answer

class Example{
public: int a,b,c;
Example(){a=b=c=1;}

SEMESTER 4 23 PROGRAMMING 622 (C++)


//Constructor 1
Example(int a){a = a; b = c = 1;}
//Constructor 2
Example(int a,int b){a = a; b = b; c = 1;}
//Constructor 3
Example(int a,int b,int c){ a = a; b = b; c = c;}
//Constructor 4
}
In the above example of constructor overloading, the following statement will call which
constructor
Example obj = new Example (1,2,3);

a. Type mismatch error


b. Constructor 2
c. Constructor 4
d. Constrcutor 1

Answer: Constructor 4

82. Which of the following is not a standard exception built in C++.


a. std::bad_typeid
b. std::bad_cast
c. std::bad_creat
d. std::bad_alloc

Answer: std::bad_creat

83. Which of the following is not a standard exception built in C++.


a. std::bad_typeid
b. std::bad_alloc
c. std::bad_cast
d. std::bad_creat

Answer: std::bad_alloc

84. Which of the following below can perform conversions between pointers to related
classes?
a. static_cast
b. cast_static

SEMESTER 4 24 PROGRAMMING 622 (C++)


c. cast_dynamic
d. dynamic_cast

Answer: static_cast

85. What is the implicit pointer that is passed as the first argument for nonstatic member
functions?
a. ‘Myself’ pointer
b. ‘self’ pointer
c. ‘this’ pointer
d. std::auto_ptr pointer

Answer: ‘this’ pointer

86. Which are the parameters for the content of the buffer?
a. start and finish
b. start
c. None of the option mentioned
d. finish

Answer: start and finish

87. What is shallow copy?


a. A shallow copy creates a copy of the dynamically allocated objects too.
b. A shallow copy just copies the values of the data as they are.
c. A shallow copy creates a copy of the statically allocated objects too
d. A shallow copy just copies the values of the data as they are and A shallow copy creates
a copy of the statically allocated objects too

Answer: A shallow copy just copies the values of the data as they are.

88. Which of the following inserts an element at the beginning of the list?
a. public class insertFront(int n)
{
Node nd= new Node(data, head, head.getNext());
nd.getNext().setPrev(nd);
head.setNext(nd);
size++;
}

SEMESTER 4 25 PROGRAMMING 622 (C++)


b. public class insertFront(int n)
{
Node nd = new Node(data, head, head.getNext());
nd.getNext().setPrev(head);
head.setNext(nd);
size++;
}
c. public class insertFront(int n)
{
Node nd = new Node(data, head, head);
nd.getNext().setPrev(nd);
head.setNext(nd);
size++;
}
d. public class insertFront(int n)
{
Node nd = new Node(data, head, head.getNext());
nd.getNext().setPrev(nd);
head.setNext(nd.getNext());
size++;
}

Answer: public class insertFront(int n)


{
Node nd= new Node(data, head, head.getNext());
nd.getNext().setPrev(nd);
head.setNext(nd);
size++;
}

89. What’s wrong? while( (i < 10) && (i > 24))


a. The test condition is always false
b. The logical operator &amp;&amp; cannot be used in a test condition
c. The while loop is an exit-condition loop
d. The test condition is always true

Answer: The test condition is always true

90. In which type of storage location are the vector members stored?

SEMESTER 4 26 PROGRAMMING 622 (C++)


a. Contiguous storage locations and Non-contiguous storage locations
b. None of the option mentioned
c. Contiguous storage locations
d. Non-contiguous storage locations

Answer: Contiguous storage locations

91. Which is optional in the declaration of vector?


a. Number_of_elements
b. Name
c. Type
d. Vector

Answer: Number_of_elements

92. Which of the following relationship is known as inheritancerelationship?


a. association relationship
b. ‘has-a’ relationship
c. none of the option mentioned
d. ‘is-a’ relationship

Answer: ‘has-a’ relationship

93. Which of the following functions below can be used Allocate space for array in memory?
a. malloc()
b. Realloc()
c. calloc()
d. calloc() and malloc()

Answer: calloc() and malloc()

94. Which of the following is not true about preprocessor directives


a. They form an integral part of the code
b. They are processed by a preprocessor
c. They begin with a hash symbol
d. They have to end with a semi colon

Answer: They begin with a hash symbol

SEMESTER 4 27 PROGRAMMING 622 (C++)


95. Value of a in a = (b = 5, b + 5); is
a. Junk value
b. 10
c. 5
d. Syntax error

Answer: Syntax error

96. When is std::bad_alloc exception thrown?


a. When new operator cannot allocate memory
b. When type requested for new operation is considered bad, thisexception is thrown
c. When alloc function fails
d. When delete operator cannot delete the allocated (corrupted) object

Answer: When delete operator cannot delete the allocated (corrupted) object

97. The following steps in a linked list

p = getnode()

info (p) = 10

next (p) = list

list = p
a. removal of a node
b. pop operation in stack
c. inserting a node
d. modifying an existing node

Answer: inserting a node

98. ‘Prime area’ in context of file system is defined as


a. It is memory area created by operating system
b. It is the main area of a web page
c. None of the option mentioned
d. It is an area into which data records are written

Answer: It is an area into which data records are written

SEMESTER 4 28 PROGRAMMING 622 (C++)


99. How do we define a constructor?
a. x~() {}
b. ~X() {}
c. X() {}~
d. X() ~{}

Answer: X() ~{}

100. Which of the following is the most common way of implementing C++?
a. A C++ editor directly compiles and executes the program
b. C++ programs are directly compiled into native code by a compiler
c. C++ programs are first compiled to intermediate code by a compiler and then executed
by a virtual machine
d. C++ programs are interpreted by an interpreter

Answer: C++ programs are interpreted by an interpreter

101. What’s wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);


a. There are too many variables in the statement
b. The first semicolon should be a colon
c. The question mark should be an equal sign
d. The conditional operator is only used with apstrings

Answer: The conditional operator is only used with apstrings

102. A continue statement causes execution to skip to


a. The next iteration of the loop
b. The first statement after the loop
c. The return 0; statement
d. The statement following the continue statement

Answer: The statement following the continue statement

103. In which order are elements retrieved from a stack?


a. In fist in fist out order
b. Largest element first smallest last
c. In last in first out
d. In a random way

SEMESTER 4 29 PROGRAMMING 622 (C++)


Answer: In last in first out

104. Which classes allow primitive types to be accessed as objects?


a. Wrapper
b. Friend
c. Storage
d. Virtual

Answer: Virtual

105. Which of the following correctly describes the meaning of‘namespace’ feature in C++?
a. Namespaces refer to the memory space allocated for names used in a program
b. Namespaces provide facilities for organizing the names in aprogram to avoid name
clashes.
c. Namespaces refer to space between the names in a program
d. Namespaces refer to packing structure of classes in a program.

Answer: Namespaces refer to the memory space allocated for names used in a program

106. The output of


{
int a = 5;
int b = 10;
cout << (a>b?a:b);
}
a. 10
b. None of the option mentioned
c. 5
d. Syntax error

Answer: 10

107. Which of the following library function below by default aborts the program?
a. Terminate()
b. Abort()
c. end()
d. exit()

SEMESTER 4 30 PROGRAMMING 622 (C++)


Answer: Terminate()

108. How many vector container properties are there in c++?


a. 3
b. 4
c. 2
d. 1

Answer: 3

109. What defines a general set of operations that will be applied to various types of data?
a. Function template
b. Template class and Class template
c. Template class
d. Class template

Answer: Template class and Class template

110. In mulit-list organization


a. Records are loaded in ordered sequence defined by collating sequence by content of the
key
b. None of the option mentioned
c. Records that have equivalent value for a given secondary index item are linked together
to form a list.
d. Records are directly accessed by record key field

Answer: Records are loaded in ordered sequence defined by collating sequence by content of
the key

111. Which one of the following is not a valid reserved keyword in C++
a. Implicit
b. Private
c. Explicit
d. Public

Answer: Implicit

112. Which of the following is a valid destructor of the class name “Country”

SEMESTER 4 31 PROGRAMMING 622 (C++)


a. void Country()
b. int ~Country()
c. void ~Country()
d. int ~Country(Country obj)

Answer: void Country()

113. Which of the following is not a file operation:


a. None of the option mentioned
b. Appending
c. Truncating
d. Repositioning

Answer: Repositioning

114. Which of the following is not a valid conditional inclusions in preprocessor directives
a. #ifundef
b. #elif
c. #ifdef
d. #endif

Answer: #ifdef

115. Which of the following is/are advantages of cellular partitioned structure:


a. Simultaneous read operations can be overlapped and Search time is reduced
b. Simultaneous read operations can be overlapped
c. Search time is reduced
d. None of the option mentioned

Answer: Simultaneous read operations can be overlapped

116. In C language, a hexadecimal number is represented by writing


a. ox
b. xo
c. x
d. h

Answer: xo

SEMESTER 4 32 PROGRAMMING 622 (C++)


117. Which of the following operator cannot be overloaded?#NAME?
a. == (equality operator)
b. :: (cope resolution operator)
c. []; (row operator)

Answer: :: (cope resolution operator)

118. A stack is an abstract data structure which stores elements in a certain way. The
addition of new element to a stack is called……
a. Push
b. Pop
c. Create
d. Add

Answer: Push

119. What is the difference between overloaded functions and overridden functions?
a. Redefining a function in a friend class is called function overloading while Redefining a
function in a derived class is called as overridden function.
b. Redefining a function in a friend class is called function overriding while Redefining a
function in a derived class is called an overloaded function.
c. Overloading is a dynamic or run-time binding and Overriding is static or compile-time
binding
d. Overloading is a static or compile-time binding and Overriding is dynamic or run-time
binding

Answer: Redefining a function in a friend class is called function overriding while Redefining a
function in a derived class is called an/a overloaded function.

120. Originally ‘C++’ was developed as:


a. System programming language
b. None of the option mentioned
c. Data processing language
d. General purpose language

Answer: Data processing language

121. There is nothing like a virtual constructor of a class.


a. True

SEMESTER 4 33 PROGRAMMING 622 (C++)


b. False

Answer: False

122. Which of the following correctly describes C++ language?


a. Dynamically typed language
b. Type-less language
c. Statically typed language
d. Both Statically and dynamically typed language

Answer: Type-less language

123. The default access level assigned to members of a class is ___________


a. Public
b. Private
c. Needs to be assigned
d. Protected

Answer: Protected

124. Which of the following is true about const member functions?


a. none of the option mentioned
b. nonconst members can be invoked on const objects as well as nonconst objects
c. const members can be invoked on both const as well as nonconst objects
d. const members can be invoked only on const objects and not on nonconst objects

Answer: const members can be invoked only on const objects and not on nonconst objects

125. If class A is friend of class B and if class B is friend of class C, which of the following is
true?
a. Class C is friend of class A
b. Class A is friend of class C
c. Class A and Class C do not have any friend relationship
d. None of the option mentioned

Answer: Class A is friend of class C

126. In a group of nested loops, which loop is executed the most number of times?
a. the innermost loop

SEMESTER 4 34 PROGRAMMING 622 (C++)


b. all loops are executed the same number of times
c. cannot be determined without knowing the size of the loops
d. the outermost loop

Answer: all loops are executed the same number of times

127. Which of the following operators can be overloaded?


a. sizeof operator
b. &(address-of operator)
c. .(dot or member access operator)
d. ?:(conditional operator)

Answer: ?:(conditional operator)

128. A direct access file is:


a. Files which are stored on a direct access storage medium
b. None of the option mentioned
c. A file in which records are arranged in a particular order
d. A file in which recoreds are arranged in a way they are inserted in a file

Answer: Files which are stored on a direct access storage medium

129. Which of the following is not recommended in a header file?


a. Class definitions
b. Type definitions (typedefs)
c. Function definitions
d. Template definitions

Answer: Template definitions

130. STL is based on which of the following programming paradigms?


a. Object Oriented Programming (OOP)
b. Functional Programming
c. Structured Programming
d. Aspect Oriented Programming (AOP)

Answer: Structured Programming

131. What does STL stand for?

SEMESTER 4 35 PROGRAMMING 622 (C++)


a. Simple Template Library
b. Standard Template Library
c. Single Type-based Library
d. Static Type Library

Answer: Standard Template Library/Simple Template Library

132. If a member needs to have unique value for all the objects of that same class, declare
the member as
a. Static variable inside class
b. Dynamic variable inside class
c. Local variable inside constructor
d. Global variable outside class

Answer: Global variable outside class

133. Which of the following is the most general exception handler that catches exception of
any type?
a. catch()
b. catch(std::exception)
c. catch(…)
d. catch(std::any_exception)

Answer: catch(std::exception)

134. What is the Difference between struct and class in terms of Access Modifier?
a. By default all the struct members are public while by default class members are
protected.
b. By default all the struct members are protected while by default class members are
private.
c. By default all the struct members are private while by default class members are public.
d. By default all the struct members are public while by default class members are private.

Answer: By default all the struct members are protected while by default class members are
private., By default all the struct members are public while by default class members are
private.

135. Which one of the following is not a fundamental data type in C++
a. wchar_t

SEMESTER 4 36 PROGRAMMING 622 (C++)


b. float
c. string
d. int

Answer: float

136. Under which of the following circumstances, synchronization takes place?


a. When the file is closed
b. When the file is closed and Explicitly, with manipulators
c. Explicitly, with manipulators
d. When the buffer is empty

Answer: When the buffer is empty

137. Vtables
a. creates a dynamic table per class
b. creates a dynamic table per object
c. creates a static table per object
d. creates a static table per class

Answer: creates a dynamic table per object

138. Which looping process is best used when the number of iterations is known?
a. for
b. all looping processes require that the iterations be known
c. while
d. do-while

Answer: for

139. The output of this program is


int
main () { cout << “Hello World!” return 0; }

a. 0
b. Hello World
c. Syntax error
d. Hello World!

SEMESTER 4 37 PROGRAMMING 622 (C++)


Answer: Syntax error

140. Consider code snippet that implements a stack.

#define MAX 12
Struct STACK
{
Int arr [MAX];
Int top = -1;
}

If the array index starts at 0 ,maximum top value that will not cause an overflow is?
a. 12
b. 10
c. 13
d. 8

Answer: 10

141. Which of the following is not an advantage of secondary memory


a. It is easily portable
b. It has large storage capacity
c. It is cost-effective
d. It has highest speed

Answer: It is cost-effective

142. Which of the following is the most preferred way of throwing and handling
exceptions?
a. Throw by reference and catch by reference.
b. Throw the pointer value and provide catch for teh pointer type.
c. Throw by value and catch by reference.
d. Throw by value and catch by value

Answer: Throw by reference and catch by reference.

143. Which of the STL containers store the elements contiguously (in adjacent memory
locations)?
a. std::set

SEMESTER 4 38 PROGRAMMING 622 (C++)


b. std::vector
c. std::list
d. std::map

Answer: std::map

144. C++ provides facility to specify that the compiler should match function calls with the
correct definition at the run time. This process is called as
a. Dynamic Binding
b. Static binding

Answer: Dynamic Binding

145. Expression C=i++ causes


a. Value of i assigned to C
b. i to be incremented by 1 and then value of i assigned to C
c. i to be incremented by 1
d. Value of i assigned to C and then i incremented by 1

Answer: i to be incremented by 1

146. The conditional compilation


a. It is taken care of by the compiler
b. It is compiling a program based on a condition
c. It is setting the compiler option conditionally
d. none of the option mentioned

Answer: none of the option mentioned

147. What is deep copy?


a. A deep copy just copies the values of the data as they are and A deep copy creates a
copy of the statically allocated objects too
b. A deep copy creates a copy of the statically allocated objects too
c. A deep copy creates a copy of the dynamically allocated objects too.
d. A deep copy just copies the values of the data as they are.

Answer: A deep copy just copies the values of the data as they are.

148. Pick out the correct statement about vector.

SEMESTER 4 39 PROGRAMMING 622 (C++)


a. vector<int> values (5)
b. vector values (5)
c. vector<int> (5)
d. None of the option mentioned

Answer: vector<int> values (5)

149. What is the purpose of the following function?

void deleteItem(){

if(head==NULL){

cout<<"List is empty!"<<endl;

return;

cout<<head->num<<" is removed."<<endl;

head=head->next;

a. Delete every element


b. Delete the list
c. Delete the first element
d. Delete the last element

Answer: Delete the first element

150. How many copies of a class static member are shared between objects of the class?
a. No memory is allocated for static members of a class
b. A copy of the static member is shared by all objects of a class
c. A copy is created only when at least one object is created from that class
d. A copy of the static member is created for each instntiation of the class

Answer: A copy of the static member is created for each instntiation of the class

151. The output of this program is

SEMESTER 4 40 PROGRAMMING 622 (C++)


int a = 10;
void main()
{
int a = 20;
cout << a << ::a;
}
a. 20 20
b. 20 10
c. 10 20
d. Syntax error

Answer: 20 10

152. *ptr++ is equivalenet to:


a. ++*ptr
b. *ptr
c. ptr++
d. None of the option mentioned

Answer: ++*ptr

153. Which of the following functions will delete the first element from a linked list?
a. static Node delete(Node head)
{
if (head == null)
return null;
Node temp = head;
head = head.next;
return head;
}
b. static Node delete(Node head)
{
if (head == null)
return null;
if (head.next == null) {
return null;
}
c. static Node delete(Node head)
{

SEMESTER 4 41 PROGRAMMING 622 (C++)


if (head == tail)
return null;
Node temp = head;
head = head.tail;
return head;
}
d. static Node delete(Node head)
{
if (head == tail)
return tail;
Node temp = head;
head = head.next;
return head;
}

Answer: static Node delete(Node head)


{
if (head == null)
return null;
Node temp = head;
head = head.next;
return head;
}

154. Which looping process checks the test condition at the end of the loop?
a. for
b. no looping process checks the test condition at the end
c. while
d. do-while

Answer: for

155. Each pass through a loop is called a/an


a. iteration
b. enumeration
c. pass through
d. culmination

Answer: culmination

SEMESTER 4 42 PROGRAMMING 622 (C++)


156. What do vectors represent?
a. Stack
b. Static arrays
c. Dynamic arrays
d. Queue

Answer: Dynamic arrays

157. Which header file should we include for using std::auto_ptr?


a. <smartptr>
b. <alloc>
c. <memory>
d. <autoptr>

Answer: <memory>, <autoptr>

158. Which of the following keyword supports dynamic method resolution?


a. abstract
b. Virtual
c. Typeid
d. Dynamic

Answer: abstract

159. If there is more than one statement in the block of a for loop, which of the following
must be placed at the beginning and the ending of the loop block?
a. parentheses ( )
b. braces { }
c. brackets [ ].
d. arrows < >

Answer: braces { }

160. Which of the following language feature is not an access specifier in C++?
a. private
b. C protected
c. public
d. internal

SEMESTER 4 43 PROGRAMMING 622 (C++)


Answer: internal

161. Statement scanf(“%d”,80);


a. Print the value of i
b. Assign an float to variable i
c. Give an error message
d. Assign an integer to variable i

Answer: Assign an integer to variable i

162. Which of the following members do get inherited but become private members in
child class
a. Protected
b. All of the option mentioned
c. Private
d. Public

Answer: Private

163. Latency time is:


a. Time taken by read/write head mechanism to position itself over appropriate cylinder
b. Time taken by appropriate sector to come under read/write head
c. None of the option mentioned
d. Time taken to transfer a dta from memory

Answer: None of the option mentioned

164. Which of the following operators can be implemented as a nonmember operator?


a. + (addition operator)
b. () (function call operator)
c. [. (array access operator)

Answer: [. (array access operator)

165. Which of the following language is not supported by C++?


a. Exception Handling
b. Reflection
c. Operator Overloading

SEMESTER 4 44 PROGRAMMING 622 (C++)


d. Namespaces

Answer: Namespaces

166. The code snippet below shows a stack being initialized. What is the maximum number
of elements that this stack will store until overflow?

#include <stdio.h>

#define MAXSIZE 5

struct stack

int stk[MAXSIZE];

int top;

};

typedef struct stack STACK;

STACK s;

a. 10
b. 5
c. Infinity
d. 7

Answer: 5

167. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const
member function)?
a. X* const
b. const X* const
c. X&
d. X*

SEMESTER 4 45 PROGRAMMING 622 (C++)


Answer: X&

168. What happens when a pointer is deleted twice?


a. It can abort the program
b. It can cause a trap
c. It can cause a failure
d. It can cause an error

Answer: It can cause an error

169. Which of the STL containers store the elements contiguously (in adjecent memory
locations)?
a. std::vector
b. std::map
c. std::list
d. std::set

Answer: std::map

170. The return value of the following code is


Class1& test(Class1 obj)
{
Class1 *ptr = new Class1();
………
return ptr;
}
a. object pointed by ptr
b. object of Class1
c. reference of Class1
d. reference to ptr

Answer: reference to ptr

171. What’s wrong? for (int k = 2, k <=12, k++)


a. The commas should be semicolons
b. There should be a semicolon at the end of the statement
c. The increment should always be ++k
d. The variable must always be the letter i when using a for loop

SEMESTER 4 46 PROGRAMMING 622 (C++)


Answer: The variable must always be the letter i when using a for loop

172. Which of the following below is /are a valid iterator type?


a. Input Iterator and Forward Iterator
b. Backward Iterator
c. Input Iterator
d. Forward Iterator

Answer: Input Iterator

173. Minimum number of temporary variable needed to swap the contents of 2 variables
is:
a. 1
b. 2
c. 0
d. 3

Answer: 0

174. Which of the following is not a component of file system


a. None of the option mentioned
b. Access method
c. Auxiliary storage management
d. Free integrity mechanism

Answer: Free integrity mechanism

175. The statement i++; is equivalent to


a. i –;
b. i = i + i;
c. i = i + 1;
d. i = i – 1;

Answer: i = i + i;

176. How do we declare an ‘interface’ class?


a. By making all the methods abstract using the keyword ‘abstract’ in a class
b. By making all the methods pure virtual in a class
c. By declaring the class as interface with the keyword ‘interface’

SEMESTER 4 47 PROGRAMMING 622 (C++)


d. It is not possible to create interface class in C++

Answer: By making all the methods pure virtual in a class

177. What happens when we try to remove an element from an empty stack?
a. Underflow
b. Overflow
c. Null collection
d. It will return 0

Answer: Underflow

178. When class B is inherited from class A, what is the order in which the constructers of
those classes are called
a. Class B first Class A next
b. Class A’s only as it is the parent class
c. Class A first Class B next
d. Class B’s only as it is the child class

Answer: Class A first Class B next

179. How do we declare an abstract class?


a. By declaring the class abstract with the keyword ‘abstract’
b. By declaring at least one method abstract using the keyword ‘abstract’ in a class
c. It is not possible to create abstract classes in C++
d. By providing at least one pure virtual method (function signature followed by ==0;) in a
class

Answer: By providing at least one pure virtual method (function signature followed by ==0;) in
a class

180. Value of ix+j, if i,j are integer type and ix long type would be
a. long integer
b. double precision
c. integer
d. float

Answer: float

SEMESTER 4 48 PROGRAMMING 622 (C++)


181. In a C language ‘3’ represents
a. A digit
b. A character
c. An integer
d. A word

Answer: A digit

182. Inline functions are invoked at the time of


a. Compile time and Depends on how it is invoked
b. Depends on how it is invoked
c. Run time
d. Compile time

Answer: Depends on how it is invoked

183. Seek time is


a. Time taken by appropriate sector to come under read/write
b. Time taken by read/write head mechanism to position itself over appropriate cylinder
c. None of the option mentioned
d. Time taken to retrieve a dta

Answer: None of the option mentioned

184. An inverted file


a. A file which stores information about records of a system
b. Locates information about data in small files that are maintained apart from actual data
record
c. None of the option mentioned
d. A file which stores opposite records

Answer: A file which stores opposite records

185. The two types of file structure existing in VSAM file are
a. Key sequence structure, exit sequenced structure
b. Key sequenced structure, entry sequenced structure
c. Entry sequence structure, exit sequenced structure
d. None of the option mentioned

SEMESTER 4 49 PROGRAMMING 622 (C++)


Answer: Entry sequence structure, exit sequenced structure

186. class derived: public base1, public base2 { } is an example of


a. Multilevel inheritance
b. Multiple inheritance
c. Polymorphic inheritance
d. Hierarchical inheritance

Answer: Multilevel inheritance

187. Which of the following languages is a subset of C++ language?


a. C language
b. C# language
c. language
d. Java Language

Answer: language

188. The worst type of coupling is


a. control coupling.
b. content coupling.
c. stamp coupling.
d. data coupling.

Answer: content coupling.

189. Which of the following is not part of the Object Oriented Design?
a. Object diagrams
b. Polymorphism
c. Encapsulation
d. Inheritance

Answer: Object diagrams

190. Which header file can be considered for multiset?


a. &lt;setmulti&gt;
b. &lt;multiset&gt; X
c. &Lt;looplter&gt;
d. &lt;set&gt;

SEMESTER 4 50 PROGRAMMING 622 (C++)


Answer: *****

Topic FOUR: RECURSION


Topic FIVE: STACKS
Topic SIX: QUEUES
Topic SEVEN: SEARCHING AND HASHING
ALGORITHMS
Topic EIGHT: SORTING ALGORITHMS
Topic NINE: BINARY TREES AND B-TREES

SEMESTER 4 51 PROGRAMMING 622 (C++)

You might also like