Question: l. Consider this code from the start of a Java method: Cbject obi String good new StrirgStudy hard!); String bad - new Strirg(Party hardl); Short

l. Consider this code from the start of a Java method: Cbject obi String good new Strirg"Study hard!"); String bad - new Strirg("Party hardl"); Short Answers Sections 5.1 Java's Object Type obj - good; goodbad; Write one more assigument statemen that can appear after these to reset the good String back to its original value. Is your assignment a widening conversion or auarrowing conversion? 2. Will the following code compile correctly? Will t run without errors? object obj, IntcEer i; String s new String("forty-to"); i-(Integer) abj 3. Write some lines of code that declares an Integer object, using the Integer wrapper class. Assign the value 42 to this object, then copy this value from the Integer object to an ordinary int variable. 4. Suppose Ihat i aud j are bulh Inlgc objecls (using the Inloger wrapper class). Wrile a statenent hal will print the sui uli aud j. 5. Suppose that b and c are Integer objects. A typical use of the clone metod looks like this: h-(nteger) c.clone); Write short clear explanation uf why the integer) type cast is required in this typical example. 6. Here is somc code to count the number of occurrences of a spccific target integcr in an array of integers: Short Answers Scction 5.2 A Bug of Objects int 1; int answer-e far (i - data.length; i) if (data[1] -= target) Al the end of the code, lhe value of answer indicales how many limes target appears in the aray. Rewrite lhe cvde s tha il works correctly when the dala array is an array of objects aud target is a non-null reserence to anobject with an equals method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
