B) getting the MAX_VALUE from the Integer class. This is not the answer. We havent talked about this yet, but Integer.MAX_VALUE is a static variable that gives the highest possible number an int can be..

C) length of the String class

D) sqrt of the Math class

E) the public static void main method in every class that is automatically run.

7)

To define a class that will represent a car, which of the following definitions is most appropriate?

7)

A)
public class CAR

B)
private class Car

C)
private class car

D)
public class Car

E)
public class car

8)

If a method does not have a return statement, then

8)

A)
it can not be called from outside the class that defined the method

B)
it must be defined to be a public method

C)
it must be an int, double, or String method

D)
it must be a void method

E)
it will produce a syntax error when compiled

9)

A class' constructor usually defines

9)

A)
how an object is initialized

B)
if the instance data are accessible outside of the object directly

C)
the number of methods in the class

D)
how an object is interfaced

E)
the number of instance data in the class

10)

Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

Another method that might be desired is one that updates the Student's number of credit hours. This method will receive a number of credit hours and add these to the Student's current hours. Which of the following methods would accomplish this?

If the instruction Swapper s = new Swapper(0, "hello", 0); is executed followed by s.toString( ); what value is returned from s.toString( )?

16)

A)
"00"

B)
"hello"

C)
0

D)
"hello00"

E)
"0"

17)

Which of the following criticisms is valid about the Swapper class?

17)

A)
The instance data y is visible outside of Swapper

B)
The instance data x is visible outside of Swapper

C)
The instance data z is visible outside of Swapper

D)
All 3 instance data are visible outside of Swapper

E)
none of the methods are visible outside of Swapper

18)

If we have Swapper r = new Swapper (5, "no", 10); then r.swap( ); returns which of the following?

18)

A)
"no510"

B)
"15"

C)
"no"

D)
nothing

E)
"510"

19)

Consider a method defined with the header: public void foo(int a, int b). Which of the following method calls is legal?

19)

A)
foo(0, 0.1);

B)
foo(0 / 1, 2 * 3);

C)
foo(0);

D)
foo( );

E)
foo(1 + 2, 3 * 0.1);

20)

Consider a method defined with the header:

public void doublefoo(double x). Which
of the following method calls is legal?

20)

A)
doublefoo(0);

B)
doublefoo(0.555);

C)
doublefoo(0.1 + 0.2);

D)
doublefoo(0.1, 0.2);

E)
all of the above are legal except for D

For the question(s) below, consider a class that stores 2 int values. These values can be assigned int values with the messages set1(x) and set2(x) where x is an int, and these values can be accessed through get1( ) and get2( ). Assume that y and z are two objects of this class. The following instructions are executed: y.set1(5); y.set2(6); z.set1(3); z.set2(y.get1( )); y = z;

21)

The statement z.get2( ); will

21)

A)
return 6

B)
return 0

C)
cause a run-time error

D)
return 5

E)
return 3

22)

If the instructions z.set2(5); and y.set1(10); are performed (after the previous instructions), which of the following is true?

22)

A)
(y == z) is still true

B)
(y.get1( ) == z.get1( )) but (y.get2( ) != z.get2( ))

C)
(y.get1( ) == z.get2( )) and (y.get2( ) == z.get1( )) but (y != z)

D)
this statement causes a run-time error

E)
(y.get1( ) == z.get1( )) and (y.get2( ) == z.get2( )) but (y != z)

23)

What is the value of z after the third statement executes below? StaticExample a = new StaticExample(5); StaticExample b = new StaticExample(12); int z = a.incr( );

23)

A)
12

B)
6

C)
13

D)
5

E)
none, the code is syntactically invalid because a and b are attempting to share an instance data

24)

If there are 4 objects of type StaticExample, how many different instances of x are there?

24)

A)
0

B)
1

C)
3

D)
4

E)
There is no way to know since any of the objects might share x, but they do not necessarily share x

25)

In Java, arrays are

25)

A) objects

B) Strings

C) interfaces

D) primitive data types if the type stored in the array is a primitive data type and objects if the type stored in the array is an object

E) primitive data types

26)

What does the following code do? Assume list is an array of int values, temp is some previously initialized int value, and c is an int initialized to 0.
for(j=0;j<list.length;j++)
if(list[j] < temp) c++;

26)

A) It finds the smallest value and stores it in temp

B) It finds the largest value and stores it in temp

C) It sorts the values in list to be in ascending order

D) It counts the number of elements equal to the smallest value in list