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,

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

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!