Professional Documents
Culture Documents
==============
Return your answers on a SCAN-TRON FORM Tuesday May 24
Use #2 pencil only
1. Class-objects store only data; never functions.
T__
F__
F__
F__
B. 1
C. 1
D. 3
F__
class GradeBook
{
public:
void DisplayMessage(){
cout << "Welcome !" << endl;
}
}
int main()
{
GradeBook myGradeBook;
DisplayMessage();
}
T__
8.
9.
F__
F__
F__
// or private:
// class code
};
T__
F__
F__
F__
class Box
{
private:
double length;
double width;
double height;
public:
mutable int accessCounter;
Box(double l = {10}, double w = {20}, double h = {30}) :
length{l}, width{w}, height{h}
{ }
};
T__
F__
F__
class Box
{
private:
double length, width, height;
Box(double l, double w, double h)
{
length = { l };
width = { w };
height = { h };
}
public:
double Volume() { return length * width * height; }
double BoxSurface()
{
return 2.0 * (length * width + length * height +
height * width);
}
};
int main()
{
Box b { 20, 10, 5};
cout << b.BoxSurface() << endl;
}
T__
F__
17. The following code-segment is syntactically correct:
struct TwoVals{int a, b;};
void main()
{
TwoVals.a = 10;
TwoVals.b = 20;
}
T__
F__
18. The following class definition is accepted by compiler:
class Example
{
public:
Example( int y )
{
data = y;
}
int getIncrementedData() const
{
return data++;
}
};
T__
F__
struct TwoVals
{
int a = 5;
int b = 10;
};
int main()
{
TwoVals v;
cout << v.a << "" << v.b;
return 0;
}
T__
F__
F__
F__
int year;
char make[20];
};
Which statement correctly declares and initializes the
structure variables ?
a.
b.
c.
d.
struct
struct
struct
struct
AUTO
AUTO
AUTO
AUTO
F__
F__
int i{24};
const int *p = {&i};
*p = {30};
T__
F__
F__
F__
T__
F__
32. The following array declaration is valid:
int blanks[];
T__
F__
T__
F__
34. The following array definition is valid:
string suit [4] = {"Clubs","Diamonds","Hearts","Spades"};
T__
F__
F__
1
2
3
4
5
6
7
8
9
*/
*/
*/
*/
*/
*/
*/
*/
*/
b. /* 2 */
c. /* 4 */
T__
F__
d. /* 5 */
int arr[3];
e. /* 6 */
F__
a. *array[0] = 'A';
c. *(array + 9) = '\0';
b. array = "ABCD";
d. *array + 9 = 'Z';
b. *(arry+2);
c. *(arry+3);
d. arry+2;
ptr=arr;
is correct.
F__
*(ptr+3)
and
*(nums+3)
are equivalent.
T__
F__
43. char name[20] = "John Q. Doe";
char *pName = name;
char letter;
Which statement below assigns 'Q' to the variable letter?
a. letter = name[5];
c. letter = &pName[5];
e. None of the above
b. letter = name[6];
d. letter = *pName[5];
F__
F__
T__
F__
F__
F__
F__
is initialized to 0.
T__
F__
F__
F__
F__
F__
56. The following range for cant be implemented, for the above
array, using auto:
for (auto i : myarray)
cout << i << " ";
T__
F__
F__
F__
59. The bubble sort algorithm, like the selection sort, performs only
one exchange per-pass.
T__
F__
60. The binary search is more efficient than the linear search
because the values in the array are not required to be in order,
sorted.
T__
F__
T__
F__
F__
F__
F__
F__
F__
F__
F__
a.
0
0
0
b. 1 -1
0
c. -1
1
0
d. None of the above
72. The following code-segment returns a run-time exception:
const char *s1{"Happy New Year"};
const char *s2{"Happy new year"};
cout << _strcmpi(s1, s2);
T__
F__
F__
F__
b. 4
c. 24
F__
F__
b. i
c. f
F__
s1{"bees"};
F__
F__
T__
F__
F__
F__
F__
F__
T__
F__
F__
F__
92.Tocreateanoutputstream,youmustdeclareastreamobjectto
beofclassifstream.
T__
F__
if(outputFile.is_open())
outputFile << "Bach \n" << "Beethoven \n" <<"Mozart \n";
outputFile.close();
T__
F__
94. The following statement is syntactically illegal because of
using \\ instead of \ for file-folder specifier:
ifstreaminputFile("c:\\demofile.txt");
T__
F__
}
T__
F__
F__
F__