Question: QUESTION 7 Suppose that b is a BagArray variable from Section 5.2, and consider these two possible statements: b.add(new Integer(42)); b.add(new Double(42.0)); Both statements compile

QUESTION 7

Suppose that b is a BagArray variable from Section 5.2, and consider these two possible statements:

b.add(new Integer(42));

b.add(new Double(42.0));

Both statements compile correctly. Select the true statement about what happens at run time:

A. Both statements will run with no errors, regardless of which one occurs first.

B. The first statement will run okay, but after adding an Integer object to the bag, you can no longer add a Double object.

C. A run-time exception occurs with either statement.

2 points

QUESTION 8

What is a primary difference between an array and a Vector from Java's Class Libraries:

A. Vectors can have more than one index.

B. Vectors can have negative integers as indexes.

C. Vectors can have positive double numbers as indexes.

D. Vectors grow automatically as needed.

2 points

QUESTION 9

Suppose that x and y are reference variables and a program activates x.equals(y). What occurs if x is the null reference?

A. A NullPointerException occurs

B. It always returns true.

C. It always returns false.

D. It returns true if y is also a null reference; otherwise it returns false.

2 points

QUESTION 10

What is the primary purpose of an Iterator object?

A. To add new objects to a collection.

B. To step through the objects of a collection one at a time.

C. To play an audio clip.

D. To display a graphical object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!