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

1.Can an Object variable refer to a String? To a Location? To an IntArrayBag? 2.

ID: 3880819 • Letter: 1

Question

1.Can an Object variable refer to a String? To a Location? To an IntArrayBag?

2.Write some code that creates a Character wrapper object called example, initializing with the char 'w'.

3.Suppose that x, y and z are all Double objects. Describe all the boxing and unboxing that occurs in the assignment z = x + y;.

4.We converted an IntArrayBag to a generic ArrayBag<E>. During the conversion, does every occurrence of int get changed to E? Explain.

5.The original countOccurrences method tested for the occurrence of a target by using the boolean expression target == data[index]. What different boolean expression is used in the countOccurrences method of the bag of objects?

6.Suppose x and y are non-null references to two nodes. The data in each node is a non-null Object. Write two boolean expressions: (1) an expression that is true if x and y refer to exactly the same node, and (2) an expression that is true if the data from the x node is equal to the data from the y node. Use the equals method where appropriate.

7.Using the generic ArrayBag class, write one to three lines of Java to perform the following:

a)Create a ArrayBag of Location

b)Add a Location to the ArrayBag

c)Remove the location created in (b) from the ArrayBag

Explanation / Answer

As per CHEGG Policy, I am unable to answer all questions. So, please repost the other questions.

Answers :

1. Yes.

An object variable can be referred to a string, to a location and also to an IntArrayBag.

2. Character example = new Character('w');

3. First, x and y are unboxed. Then the double numbers are added, resulting in a double answer. This answer is boxed and assigned to z.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote