Given: Which statement, when inserted into line 5, is valid change?
A.
asc = sc.clone ()
B.
asc = sc;
C.
sc = asc;
D.
asc = (object) sc;
Given: Which statement, when inserted into line 5, is valid change?
A.
asc = sc.clone ()
B.
asc = sc;
C.
sc = asc;
D.
asc = (object) sc;
C
Answer: C
Explanation:
A is wrong because clone() returns and Object and is not possible to convert from Object to AnotherSampleClass.
B is wrong because we cannot convert from SampleClass to AnotherSampleClass.
D is wrong because is not possible to convert from Object to AnotherSampleClass.