package polymorphism;class TestSup { static int p = 100;}public class TestPoly extends TestSup { public static void main(String[] args) { TestPoly TP = new TestPoly(); TP.p = 400; TestSup TS = new TestSup(); TS.p = 100; TestSup TSP = new TestPoly(); TSP.p = 500; System.out.print("TestSup = " + TestSup.p); System.out.print(" ,TestPoly = " + TestPoly.p); System.out.print(" ,TP = " + TP.p); System.out.print(" ,TS = " + TS.p); System.out.print(" ,TSP = " + TSP.p); }}

  1. TestSup = 100 ,TestPoly = 400 ,TP = 500 ,TS = 500 ,TSP = 500

  2. TestSup = 500 ,TestPoly = 500 ,TP = 500 ,TS = 500 ,TSP = 500

  3. TestSup = 100 ,TestPoly = 400 ,TP = 400 ,TS = 100 ,TSP = 500

  4. TestSup = 500 ,TestPoly = 400 ,TP = 500 ,TS = 100 ,TSP = 400


Correct Option: B

AI Explanation

To answer this question, let's go through each option and analyze the code:

Option A) TestSup = 100, TestPoly = 400, TP = 500, TS = 500, TSP = 500

In this option, the values of TestSup.p and TestPoly.p are incorrect. The correct values are 500 for both variables.

Option B) TestSup = 500, TestPoly = 500, TP = 500, TS = 500, TSP = 500

This option is the correct answer. After modifying the values of the variables, TestSup.p, TestPoly.p, TP.p, TS.p, and TSP.p are all set to 500.

Option C) TestSup = 100, TestPoly = 400, TP = 400, TS = 100, TSP = 500

In this option, the values of TP.p and TS.p are incorrect. The correct values are 500 for both variables.

Option D) TestSup = 500, TestPoly = 400, TP = 500, TS = 100, TSP = 400

In this option, the values of TestPoly.p, TS.p, and TSP.p are incorrect. The correct values are 500 for all three variables.

The correct answer is option B) TestSup = 500, TestPoly = 500, TP = 500, TS = 500, TSP = 500.

Find more quizzes: