c++ 1.You can use #define to define a name for a C++ variable. True/False 2.Supp
ID: 3844383 • Letter: C
Question
c++
1.You can use #define to define a name for a C++ variable.
True/False
2.Suppose an exception of type E is thrown in a function but not listed in the exception specification, and is not caught in the function. The exception will be caught in a calling function that has a catch block that declares an exception of that type.
True/False
3.Setting the width of output with call to the width member function, affects only the next output.
True/False
4.Most applications that use a stack will store a struct or class object on the stack.
True/False
5.
The operator * is prefixed to an iterator to insert an element in the container.
True/False
6.A function does not have an exception specification at all, so exceptions are prohibited.
True/False
7)A base/member initialization list produces results that are exactly _______
a)assignment
b)redeclaration
c)redefinition
initialization
e)output
8)
It is useful to define a class for which no objects may be defined.
True/False
9)The binary search algorithm in the text makes recursive on subarrays of the array passed to the algorithm. The index values of the array the algorithm searches run from first to last. The subarrays are dermined using the mid-point. How is the mid point calculate?
a)mid=(first - last)/2;
b)mid=(first + last)/2;
c)mid=(first + last)%2;
d)mid=(first - last)%2;
10)
A tree is a recursive structure.
True/False
11)In type matching to select a catch block, only exact matches work.
True/False
12)Which of the following can be virtual?(can have mutiple answers)
a)Constructors
b)Destructors
c)Ordinary functions
d)friend functions
e)static functions
13)If the override specifier is added to the end of a member function declaration, what happens if the function is not specified as virtual in the parent class?
a)the function is overridden in the derived class
b)there is a compiler error.
c)the funtion in the parent class will always be invoked.
a)assignment
b)redeclaration
c)redefinition
d)initialization
e)output
Explanation / Answer
1.) The #define preprocessor directive creates symbolic constants. The symbolic constant is called a macro.
this is defined as - #define identifier replacement
for example , #define SIZE 50.
Answer is FALSE.
2) The function has to throw the exception so that it will be caught by Calling Function. If it is not listed, then there is no way for calling function to catch it.
Answer is FALSE
4) Not Necessarily. Members of Struct goes into contigous memory allocations. For classes - member variables are stored in stack, while class instance stores in Heap
Answer is FALSE
6) Exceptions are inevitable. no one can stop them. Best way is to handle them using try - catch
Answer is FALSE
8) Static classes have no objects but still they are useful
Answer is TURE
9) ANSWER is A. mid=(first - last)/2;. %2 is not at all right , so straight forward 2 choices are wrong. The choice B mid=(first + last)/2 can lead to overflow exception.
10) YES , Tree is a recursive structure, where each node is a root and childs unless leaf nodes.
12) Only Ordinary functions can be virtual.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.