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. UX

  2. tcs

  3. null

  4. Exception

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

The output is null, not 'tcs' or 'UX'. The testPoly() method returns a TestPolymorphism2 object, but the return value is discarded - it's not assigned to TSuper. TSuper.name remains null because the superclass's name field was never initialized (the subclass's local name is different).