CS280 Final Exam Study Guide With
Complete Solutions
In C++ and Java, it is possible to create an infinite loop out of while and do loops
but not for loops. - ANSWER False
The function header void SomeFunc(char arr[]); can be interchangeable with the
heading void SomeFunc(char* arr); - ANSWER True
The binding of actual parameters to formal parameters in C/C++ is by position. -
ANSWER True
The Environment Pointer (EP) is a variable maintained by the run-time system. It
always points at the base of the activation record instance of the currently
executing program unit. - ANSWER True
C++ supports multiple inheritance, but Java directly supports only single
inheritance. - ANSWER True
C++ provides two constructs, the class and the struct, which support directly
abstract data types - ANSWER True
The type of the reference, not the type of the object, is used to determine which
version of a method is invoked in a polymorphic reference. - ANSWER False
A C++ class that has at least one virtual function is an abstract class. - ANSWER
False
A switch statement in C++ or Java must have a default clause. - ANSWER False
In Java, all objects are allocated from the heap and accessed through reference
variables. - ANSWER True
What are the values of x, y and z after the execution of the following statements?
int x = 3;
int y = ++x; int z = x++;
a. x = 4, y = 4, z = 3
b. x = 5, y = 4, z = 4
c. x = 4, y = 3, z = 3
d. x = 5, y = 3, z = 4 - ANSWER B
, Consider the following C++ program, what is the output generated in the main
function, assuming operands are evaluated left to right in the statement at
position 1?
int fun (int x, int &y)
{
++x; y++; return x;
}
int main()
{
int k = 3, j = 11;
do {
j = j - fun(k, j);//position 1
cout << k <<", "<< j << ", ";
} while(++k < 5);
return 0;
}
a. 3, 7, 4, 2,
b. 4, 7, 5, 2
c. 3, 7, 5, 2
d. 4, 8, 5, 4 - ANSWER A
LOOK AT 3 - ANSWER A
What will be the value of x after the following statements are executed? int x =
12; switch (x) { case 10: x += 15; break; case 12: x -= 5; default: x *= 3; }
a. 15
b. 21
c. 27
d. 7 - ANSWER B
Individual entities in Java classes have access control modifiers, called visibility
modifiers, that are attached to method and variable definitions. These include:
a. public, private
b. public, private, protected
c. public, private, protected, final
d. public, private, protected, static - ANSWER B
A continue statement in C/C++ and Java
a. may be used within a while or a do-while loop but not a for loop
b. is identical to a break statement within loops
c. may be used within any loop statement
Complete Solutions
In C++ and Java, it is possible to create an infinite loop out of while and do loops
but not for loops. - ANSWER False
The function header void SomeFunc(char arr[]); can be interchangeable with the
heading void SomeFunc(char* arr); - ANSWER True
The binding of actual parameters to formal parameters in C/C++ is by position. -
ANSWER True
The Environment Pointer (EP) is a variable maintained by the run-time system. It
always points at the base of the activation record instance of the currently
executing program unit. - ANSWER True
C++ supports multiple inheritance, but Java directly supports only single
inheritance. - ANSWER True
C++ provides two constructs, the class and the struct, which support directly
abstract data types - ANSWER True
The type of the reference, not the type of the object, is used to determine which
version of a method is invoked in a polymorphic reference. - ANSWER False
A C++ class that has at least one virtual function is an abstract class. - ANSWER
False
A switch statement in C++ or Java must have a default clause. - ANSWER False
In Java, all objects are allocated from the heap and accessed through reference
variables. - ANSWER True
What are the values of x, y and z after the execution of the following statements?
int x = 3;
int y = ++x; int z = x++;
a. x = 4, y = 4, z = 3
b. x = 5, y = 4, z = 4
c. x = 4, y = 3, z = 3
d. x = 5, y = 3, z = 4 - ANSWER B
, Consider the following C++ program, what is the output generated in the main
function, assuming operands are evaluated left to right in the statement at
position 1?
int fun (int x, int &y)
{
++x; y++; return x;
}
int main()
{
int k = 3, j = 11;
do {
j = j - fun(k, j);//position 1
cout << k <<", "<< j << ", ";
} while(++k < 5);
return 0;
}
a. 3, 7, 4, 2,
b. 4, 7, 5, 2
c. 3, 7, 5, 2
d. 4, 8, 5, 4 - ANSWER A
LOOK AT 3 - ANSWER A
What will be the value of x after the following statements are executed? int x =
12; switch (x) { case 10: x += 15; break; case 12: x -= 5; default: x *= 3; }
a. 15
b. 21
c. 27
d. 7 - ANSWER B
Individual entities in Java classes have access control modifiers, called visibility
modifiers, that are attached to method and variable definitions. These include:
a. public, private
b. public, private, protected
c. public, private, protected, final
d. public, private, protected, static - ANSWER B
A continue statement in C/C++ and Java
a. may be used within a while or a do-while loop but not a for loop
b. is identical to a break statement within loops
c. may be used within any loop statement