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

String s1; // 1 Integer i = 99; // 2 String qu1 = new String(“Is this question f

ID: 3596572 • Letter: S

Question

String s1; // 1
Integer i = 99; // 2
String qu1 = new String(“Is this question fair?”); // 3
String qu2 = qu1; // 4
qu1 = null; // 5
THE FOLLOWING 4 QUESTIONS REFER TO THE CODE FRAGMENT ABOVE
13. Line 1 does not create an instance of String:
(a) TRUE
(b) FALSE

14. In line 2, what feature of Java allows us to assign an integer (int) value to a
reference of the Integer Class?
__________________________________________________

15. How could line 3 have been re-written without changing the outcome of running
the code snippet within a complete runnable program?
__________________________________________________


16. By the time line 5 has been executed, the object instance created on line 3 is a
candidate for garbage collection.
(a) TRUE
(b) FALSE

Explanation / Answer

Q.13) (a) TRUE
Yes an instance of string is not created at line 1

Q.14) The feature is called autoboxing.
Java Versions after 5 included autoboxing.

Q.15) String qu1 = "Is this question fair?";
Just remove the object format

Q.16)(a) TRUE
As there is no further use of qu1 it will be a candidate for garbage collection.

**Comment for any further queries. Upvote if the answer is satisfactory.