Tag: programming languages

Questions Related to programming languages

  1. login com.tcs.login.LoginServlet login /utils/L

  2. com.tcs.login.LoginServlet /utils/LoginServlet

  3. com.tcs.login.LoginServlet /utils/LoginServlet

  4. login com.tcs.login.LoginServlet login /utils/LoginServlet


Correct Option: A
  1. login com.tcs.login.LoginServlet mailId [email protected]

  2. login com.tcs.login.LoginServlet mailId [email protected]

  3. login com.tcs.login.LoginServlet mailId

  4. login com.tcs.login.LoginServlet mailId [email protected]


Correct Option: A

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.

package polymorphism;class TestSuperr { double TestPoly(long a, float b, int c) { return ((a + b) * c); }}public class TestPolym extends TestSuperr { double TestPoly(long a, double b, int c) { return (a + b + c); } public static void main(String[] args) { TestSuperr TSU = new TestPolym(); double p = TSU.TestPoly(11, 9, 10); System.out.print("p = " + p); p1 = TSU.TestPoly(11, 9.0, 10); System.out.print(" ,p1 = " + p1); }}

  1. p = 200.0, p1 = 30.0

  2. p = 200.0, p1 = 200.0

  3. p = 30.0, p1 = 30.0

  4. Compiler Error


Correct Option: D

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

  1. TestSupe = 300 ,TestPoly = 400 ,TP = 400 ,TS = 300 ,TSP = 500

  2. TestSupe = 500 ,TestPoly = 400 ,TP = 400 ,TS = 500 ,TSP = 500

  3. TestSupe = 500 ,TestPoly = 400 ,TP = 400 ,TS = 300 ,TSP = 500

  4. TestSupe = 300 ,TestPoly = 400 ,TP = 500 ,TS = 500 ,TSP = 500


Correct Option: B
  1. The signature of a method is the name of the method the type of its return value.

  2. The signature of a method is the name of the method and the names of its parameters.

  3. The signature of a method is the name of the method and the data types of its parameters.

  4. The signature of a method is the name of the method, its parameter list, and its return type.


Correct Option: D
  1. The same program logic can be used with objects of several related types.

  2. Variables can be re-used in order to save memory.

  3. Constructing new objects from old objects of a similar type saves time.

  4. Polymorphism is a dangerous aspect of inheritance and should be avoided.


Correct Option: A