Multiple choice technology programming languages

package polymorphism; class TestPolymorphismSuper1 { String name; TestPolymorphism2 testPoly() { TestPolymorphism2 TS = new TestPolymorphism2(); TS.name ="tcs"; return TS; } } public class TestPolymorphism2 extends TestPolymorphismSuper1{ TestPolymorphism2 testPoly() { TestPolymorphism2 TSub = new TestPolymorphism2(); TSub.name = "UX"; return TSub; } public static void main(String[] args) { TestPolymorphismSuper1 TSuper = new TestPolymorphism2(); TSuper.testPoly(); System.out.println(TSuper.name); } }

  1. tcs

  2. UX

  3. null

  4. Exception

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The testPoly() method returns a new TestPolymorphism2 object with name "UX", but this return value is not assigned to TSuper. TSuper.name remains uninitialized (null) because TSuper itself was never directly modified. The key insight is that calling an overridden method on a polymorphic reference doesn't change the reference itself - only the returned object would have the new value if assigned.