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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started