Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 7 Suppose that b is a BagArray variable from Section 5.2, and consider

ID: 3878955 • Letter: Q

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 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

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.

Explanation / Answer

7) A. Both statements will run with no errors, regardless of which one occurs first.
8) D. Vectors grow automatically as needed.
9) A. A NullPointerException occurs
10) B. To step through the objects of a collection one at a time.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote