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

Given a variable A that contains a reference to an object of type MyClass, which

ID: 3527625 • Letter: G

Question

Given a variable A that contains a reference to an object of type MyClass, which of the following best describes the effect of the code below? MyClass B = A; (A) It sets an existing variable B to contain a refrence to the same object as A (B) It sets an existing variable A to contain a refrence to the same object as B (C) It creates and initialises a variable A to contain a reference to the same object as B (D) It creates and initialises a variable B to contain a reference to the same object as A (E) It returns true if A and A refer to the same object. What I think: D because MyClass B = A is just like String B = A

Explanation / Answer

Yes.

It creates and initialises a variable B to contain a reference to the same object as A

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote