0

programming languages Online Quiz - 185

Description: programming languages Online Quiz - 185
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0
  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

Which element guarantees a servlet will be loaded on the start up of the web application

  1. true

  2. 1

  3. 0


Correct Option: B

How to define a session time out of 10 minutes in web.xml

  1. 10

  2. 600

  3. 600

  4. 60 session-invalid-time>


Correct Option: A

Which is the correct definition of servlet init parameter in web.xml?

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


Correct Option: C

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

What is an advantage of polymorphism?

  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

AI Explanation

To answer this question, you need to understand the concept of polymorphism.

Polymorphism is a fundamental concept in object-oriented programming that allows objects of different classes to be treated as objects of a common superclass. It enables the same code or program logic to be used with objects of several related types.

Let's go through each option to understand why it is correct or incorrect:

Option A) The same program logic can be used with objects of several related types. - This option is correct. Polymorphism allows objects of different classes to be treated as objects of a common superclass. This means that the same program logic or code can be written to operate on objects of different classes, as long as they are related through inheritance. This promotes code reusability and flexibility.

Option B) Variables can be re-used in order to save memory. - This option is incorrect. Polymorphism is not directly related to variable reusability or memory saving. Polymorphism focuses on the behavior and interaction of different objects, rather than the reuse of variables.

Option C) Constructing new objects from old objects of a similar type saves time. - This option is incorrect. Constructing new objects from old objects of a similar type is not directly related to polymorphism. This concept is known as object cloning or object copying, and it is not a unique advantage of polymorphism.

Option D) Polymorphism is a dangerous aspect of inheritance and should be avoided. - This option is incorrect. Polymorphism is not a dangerous aspect of inheritance. In fact, it is one of the powerful features of object-oriented programming that promotes code reusability, flexibility, and extensibility.

The correct answer is A) The same program logic can be used with objects of several related types. This option is correct because polymorphism allows objects of different classes to be treated as objects of a common superclass, enabling the same program logic or code to be used with objects of different classes.

  1. for

  2. break

  3. continue

  4. Structure


Correct Option: D

What command is used to compile a program in Java

  1. javac

  2. java

  3. run java

  4. javas


Correct Option: A
  1. One per defined class.

  2. One per constructor definition.

  3. As many as the program needs.

  4. One per program


Correct Option: C
  1. balance resource loading

  2. lower cost of development since clients can access remote codes for services

  3. operator overloading

  4. none of these


Correct Option: A,B

Is it OK if a class definition implements two interfaces, each of which has the same definition for a constant PI?

  1. True

  2. False


Correct Option: B

Is "java.lang.Object" a valid class in java?

  1. True

  2. False


Correct Option: A

"JAVA" stands for Just Another Virtual Analyser

  1. True

  2. False


Correct Option: B

Current version of java is 1.5

  1. True

  2. False


Correct Option: B
  1. A pattern (design) whereby collaborators are passed into an object from the outside - the object does not allocate them for itself.

  2. It is a pattern in which the child class inherit the parent class properties

  3. It is a type of operator overloading in java

  4. It represents the compile time and run time polymorphism in java


Correct Option: A
- Hide questions