Você está na página 1de 11

1.

Signature of the function include…

a) Number of parameter
b) Types of parameters
c) Function name
d) All of above
Answer: d) Return type is not included in signatures
2. In passing parameters by reference, can the passed parameter be an expression
or a constant.
Answer: No, in passing by reference, it must be a variable.
3. A break statement inside a nested if, will do what:

a) The control will be transferred to the outer if


b) The control will be returned back to next statement in the outer scope
c) It will be an error
Answer: ( c )
4. Arrays can be passed by value, if yes, then explain how, if no, give reason:

Answer: Arrays can only be passed by value using structure. Otherwise array are
always passed by reference.
5. What is the difference between external variables and external static variable.:

The difference is in their scope:


Answer: External variable can be used by function is any file.
External static variable can be used only be function in the same file.
6. Left shifting an integer by 3 places has the same effect as dividing it by 8. (T/ F)

Answer: False
7. Header files can contain the main() function (T/ F)

Answer: False
8. Macros are more efficient then function in the terms of the speed of code
execution and memory size (T/ F)
Answer: False. Macros are efficient in terms of speed of code execution but
functions are more efficient in terms of memory size.
9. File mode ‘ab’ stands for:

Answer: Open a binary file for appending. If file does not exist, a new file will be
created.
10. Assignment operator cannot be used to assign an array to another. (T/ F)

Answer: True
11. The precedence of -> arrow operator is:

a) geater than
b) less than
c) equal to
the dot operator?
Answer: ( c )
12. If there are more initializers then the number of variables then:

a) compiler will ignore


b) compiler will give an error
Answer: ( b )
13. The declaration of the structure containing one character and one pointer to
double will occupy how many bytes in the memory!
Answer: zero bytes
14. The keyword ‘extern’ is used to create a new external variable (T/ F)

Answer: False. Extern just tells the compiler that this variable is already defined.
15. A language construct that allows the compiler to generate multiple versions of a
class by allowing parameterized data type is called?
Answer: Arrays
16. The name of an array is:

a) pointer constant
b) pointer variable
Answer: ( a )
17. In C++ generally the near pointer take 2 bytes. The size of pointer to pointer to
float will take:
a) 6 bytes
b) 4 bytes
c) 2 bytes
Answer: ( c )
18. A friend fuction can access a class private data, only if it is a member function of
the class (T/ F)
Answer: False.
19. A pure virtual function is a virtual function that:

a) caused its class to be abstract


b) return nothing
c) is used in a base class
d) takes no arguments
Note: You can choose more than one option.
Answer: ( a ) and ( c )
20. The int i is a member variable in a class, then will the statement

“this.i” = 87;
within the class assign 87 to it
Answer: No, this is a pointer therefore this -> i= 87 will be correct.
21. Command line arguments are accessible only from disk files through arguments
to main(). ( T / F )
Answer: Ture
22. Current position of file pointer indiates the current byte location which is just read
or write. ( T / F )
Answer: False. Next read/ write byte location.
23. Some streams work with output and some with input

Answer: True
24. A copy constructor could be defined to copy only a part of an object ’s data. ( T / F
)
Answer: True.
25. The compiler always provides a default copy constructor. ( T / F )

Answer: True
26. A friends class can be used to increase the versatility of an overloaded operator
and to allow access to an unrelated class ( T / F )
Answer: True
27. The contents of 2 pointers that point to adjacent variables of type float by how
many bytes?
Answer: 4 bytes.
28. If you want to sort many large objects or structures, the most efficient way would
be:
a) place them in an array and sort the array
b) place pointer to them in an array and sort the array
c) place them in a linked list and sort the linked list
Answer: ( b )
29. A “.H” file is associated with a .cpp file using What?

Answer: # include directive


30. The interface is private and implementation is public ( T / F )

Answer: False
31. A function declaration doesn’t require the keyword ‘extern ’ ( T / F )

Answer: True
32. A variable defined within a function body can be seen throughout the file in which
it is defined. ( T / F )
Answer: False
33. Using typedef allows you to shorten long variable name ( T / F )

Answer: False. (It allows you to substitute one type name or one class name to
another)
34. A global variable is defined in file F1. To access the variable in file F2, you must:

a) define it in F1 using extern


b) define it in F2 using keyword extern
c) declare it in F2 using keyword extern
Answer: ( c )
35. The files that are actually combined by the linker are called ___________ files.

Answer: object files. (.obj File )


36. The #if !defined( ) … #end if construction can be used to prevent multiple
definitions when a header file is included in two source files. ( T / F )
Answer: False. When a header file is included in another header file and both are
included in a source file.
37. Adding a derived class to a base class require fundamental changes to the base
class ( T / F )
Answer: False
38. State whether composition is a stronger or weaker form of aggregation?

Answer: stronger
39. it is illegal to make objects of one class, members of another class. ( T / F )

Answer: True
40. If a base class and a derived class each include a member function, with the
same signatures, which member function will be called by an object of the base
class assuming the scope resolution operator is not used?
Answer: function of base class
41. Aggregation is a ________________ relationship

a) has a
b) is a
Answer: ( a )
42. If a class B is privately derived from class A. An object of class B located in main
() can access public and protected member of class A.
Answer: False. Only public member can be accessed.
43. A class hierarchy describes “is a kind” of relationship. ( T / F )

Answer: True
44. To be accessed from a member function of the derived class, data or functions in
the base class must be:
a) public
b) protected
c) public or protected
Answer: ( c )
45. Templates automatically create different versions of a function, depending on
user input. ( T / F )
Answer: False. Different functions are created at compile time.
46. A template class works with different data types. ( T / F )

Answer: True
47. A statement that throws an exception doesn’t need to be located in a try block.
(T/F)
Answer: True
48. Actual code for a template function is generated when:

a) the function declaration appears in the source code


b) the function definition appears in the source code
c) a call to function appears in the source code
Answer: ( c )
49. Talking about dependencies, which is the correct statement:

a) template class is a dependent element and an instantiation class is independent


b) template class in independent and instantiated class is dependent
Answer: ( b )
50. Exceptions are thrown:

a) from a throw statement to a catch block


b) from the throw statement to a try block
c) from the print of error to a catch block
Answer: ( a )
51. An exception is typically caused by runtime error. ( T / F )

Answer: True
52. The operator overloading is giving new meanings to existing C++ operators. ( T /
F)
Answer: True
53. How many arguments are required in the definition of an overloaded unary
operator!
Answer: None
54. The operator >= can be overloaded. ( T / F )

Answer: True
55. An overloaded operator always requires one less argument than its number of
operands. ( T / F )
Answer: True
56. It will be an error to overload ‘*’ operator to perform division. ( T / F )

Answer: False
57. An STL (Standard Template Library) algorithm is a standalone function that
operates on containers. ( T / F )
Answer: True
58. An iterator in the STL is used to connect algorithm and containers.

Answer: ?
59. An iterator can always move forward or backward through a container. ( T / F )

Answer: False. An iterator points to a specific element in container.


****************************************************************************************************
****************************************************************************************************
Some questions added :
1. Name the operator overloaded by default?
Answer: =
2. Operator overloading and function overloading are synonyms. IF you disagree give
reason?
Answer: No.
3. for ( ; 1 ; ); is :
a) error
b) infinite loop
c) finite loop
Answer: ( b )
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
****************************************************************************************************
*****************************************************************
60. What is the return value of malloc? What does it return if the operating system
cannot dynamically allocate the memory requested?
61. What are the three standard streams automatically opened for every program?
62. Indicate which functions would be used to perform the following:

1. compare two strings without regard to case.


2. duplicate a specific number of characters from a string.
3. separate a string into tokens separated by delimiters.
4. add characters from one string to the end of another.
63. Name the function that can be used to display the string str, without using printf.
64. What two basic types of functions are there in ctype.h?
65. If you 9want to initialize all elements of array to zero but do not want to do it
yourself, define array as
a) Automatic
b) Register
c) global
d) None of above
66. The function fgets() will keep on reading characters from file until it finds a
__________ character.
67. In __________ mode, the translation of linefeed character to carriage return and
line feed takes place while reading.
68. Amount of memory used for different variables depends upon:
a) compiler
b) hardware
c) C language specifications
d) All of above

69. Define directives are replaced by their corresponding expressions before


_________.
70. The format specifier, __________ is used to print the value of a double.
71. The precedence of unary operator is __________ as compared to binary
operators.
72. Every character takes ___________ byte(s) for storage in display memory.
73. Program compilation starts from __________.
74. When we try to open a file in read “r” mode, while file dose not exist:
a) A default system file is opened
b) A file with same name is created and opened
c) Function fails

75. Standard I/O cannot be redirected. (T/F)


76. printf() is a built-in function and cannot be redefined. (T/F)
77. The address operator ‘&’ is evaluated at runtime. (T/F)
78. Structures are stored in a linear way in memory. (T/F)
79. Violations of rules of language are called
a) Syntax error
b) Language error
c) Semantic error
d) All of above

80. Subtraction and addition operations are not defined for pointer arithmetic. (T/F)
81. Static variable is created:
a) Each time the function in which they are defined is called
b) At start of program
c) Like global variables
d) First time the function containing them is called.

82. While defining and initializing a 2-dimentional array, first dimension can be
ignored. (T/F)
83. Null Pointer Assignment is
a) Run time error
b) Compile time error
c) Linker error
d) Logical error

84. In all selection structures, negative values are interpreted as true. (T/F)
85. Disk I/O operations are performed on entities called:
a) Clusters
b) Bytes
c) Files
d) Sectors

86. Array notation compiles into faster and more efficient code then pointer notation.
(T/F)

87. A nested if else structure is much more efficient then a series of single selection if
structures. (T/F)
88. Scanf( )uses any white space characters to terminate entry of a variable. (T/F)
89. All keys of keyboard generate one byte ASCII code (T/F)
90. rvalue can be used in place of lvalue but the reverse is not true. (T/F)
91. All operators except ‘=’ have associativity from left to right. (T/F)
92. All relational operators have same level of precedence and associate from left to
right (T/F)
93. Memory addresses are stored in RAM (T/F)
94. When an extended key is pressed, then two bytes are generated, first is NULL
and second is ‘ASCII’ code. (T/F)
95. Standard output can only be sent to monitor(T/F)
96. The term “coercion” refers to:
a) Explicit typecasting
b) Implicit typecasting

97. fopen() function takes two parameters, first name of file as string, second file
opening mode as char. (T/F)
98. Header files are included in a program:
a) Before compilation
b) At compilation time
c) After compilation
d) Just before loading

99. sizeof() is a function in C language that gives us the size of the variable given
as argument. (T/F)
100. Modulus operator (%) is an arithmetic operator that can be used with Integers
and Floating-point numbers (T/F)
101. A called function can only return control to the calling function by using
return statement. (T/F)
102. Call by reference increases security of data. (T/F)
103. Structure elements can only be of primitive data type. (T/F)
104. A variable remains visible in the nested scopes but not in its outer scope
(T/F)
105. Static variables are created in the function’s local memory.(T/F)
106. switch () statement is time efficient than the if-else structure. (T/F)
107. global variables are destroyed:
a) When function ends that use them
b) 8When program terminates
108. If and Else statements are mutually exclusive. (T/F)
109. Formal parameters of a function are the local variables (T/F)

Você também pode gostar