0

architecture Online Quiz - 19

Description: architecture Online Quiz - 19
Number of Questions: 20
Created by:
Tags: architecture
Attempted 0/20 Correct 0 Score 0

public class Va { public static void main(String[] args) { doCalc(1,2); doCalc(2); } //Point1. code to be inserted here } Which of the following inserted individually at Point1 will compile?

  1. Static void doCalc(int x, int… args) {}

  2. Static void doCalc(int… args, int x) {}

  3. Static void doCalc(int[] args)

  4. Static void doCalc(int args…)


Correct Option: A

public class NumbPlay { int x=5; public static void main(String[] args) { new NumbPlay().doPlay(); } void doPlay() { int x; System.out.println(++x); } } The output is

  1. 5

  2. 6

  3. Compile error

  4. Runtime error


Correct Option: C

try {int x = Integer.parseInt(“one”);} Which of the following could be used to create appropriate catch block ?

  1. ClassCastException

  2. IllegalStateException

  3. NumberFormatException

  4. None


Correct Option: C

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) ClassCastException - This option is incorrect because ClassCastException is thrown when there is an invalid cast operation. In this case, the error is not related to casting, so ClassCastException is not the appropriate catch block.

Option B) IllegalStateException - This option is incorrect because IllegalStateException is thrown when the state of an object is invalid for the requested operation. In this case, the error is not related to the state of an object, so IllegalStateException is not the appropriate catch block.

Option C) NumberFormatException - This option is correct because NumberFormatException is thrown when an invalid string representation of a number is attempted to be converted to a numeric type. In this case, the error occurs during the parsing of the string "one" to an integer, so NumberFormatException is the appropriate catch block.

Option D) None - This option is incorrect because we need a catch block to handle the exception that may occur during the execution of the code. So, the appropriate catch block is required.

The correct answer is C) NumberFormatException. This option is correct because NumberFormatException is the appropriate catch block for handling the exception that occurs when trying to parse the string "one" into an integer.

import java.util.Iterator; import java.util.Set; import java.util.TreeSet; public class TreeTypeSet { public static void main(String[] args) { // TODO Auto-generated method stub Set set = new TreeSet(); set.add("2"); set.add(3); set.add("1"); Iterator it = set.iterator(); while (it.hasNext()) { System.out.print(it.next()+" "); } } } Output is

  1. 1 2

  2. 1 2 3

  3. Compile error

  4. Runtime exception


Correct Option: D

Which of the following method names follow the JavaBeans standard ?

  1. addSize

  2. getCust

  3. deleteRep

  4. putDimensions


Correct Option: B

Which will legally declare, construct, and initialize an array?

  1. int [] myList = {"1", "2", "3"};

  2. int [] myList = (5, 8, 2);

  3. int myList [] [] = {4,9,7,0};

  4. int myList [] = {4, 3, 7};


Correct Option: D

Identify the advantages of JSP over Servlet.

  1. Embedding of Java code in HTML pages

  2. Platform independence

  3. Creation of database-driven Web applications

  4. Server-side programming capabilities


Correct Option: A

What are the life-cycle methods of JSP?

  1. jspInit(), _jspService() & jspDestroy()

  2. init(), service(), destroy()

  3. doPost()

  4. none of the above


Correct Option: A

What is the role of JSP in MVC Model?

  1. View

  2. Model

  3. Controller

  4. None


Correct Option: A

What do you understand by JSP translation?

  1. Parsing JSP using an XML Parser.

  2. Converting JSP into static Html content.

  3. Generating Servlet Code for the Jsp

  4. None


Correct Option: C

What are the J2EE clients from the below list?

  1. Applets

  2. Web Browsers

  3. Wireless clients.

  4. All the above


Correct Option: D

Can we have pure java code inside JSP

  1. True

  2. False


Correct Option: A

Every Custom Servlet extends javax.servlet.http.HttpServlet class

  1. True

  2. False


Correct Option: B

Web container translates JSP to Servlet for every request of the JSP

  1. True

  2. False


Correct Option: B

A JSP page can include another JSP page but not an HTML page

  1. True

  2. False


Correct Option: B

Can we write a constructor for servlet?

  1. Yes, but always call the default constructor.

  2. Yes, but you do not have to always call the default constructor.

  3. No

  4. None


Correct Option: A

What are the different scopes available?

  1. page, request & session

  2. page, request & application.

  3. page, request, session & application.

  4. request, session & application.


Correct Option: C

Which statement below is true?

  1. ServletContext gives information about Container

  2. ServletContext gives information about Request

  3. ServletContext gives information about Session

  4. None


Correct Option: A

Which are implicit objects in a JSP?

  1. only request, response

  2. only request, response & application

  3. request, response, session & application

  4. none of the above


Correct Option: C

Difference between GET & POST method. (Choose the right answer)

  1. Query length is limited in POST, not limited in GET.

  2. POST is secured whereas data is been submitted as part of URL in GET (not secured).

  3. By using POST method, we cannot submit the form.

  4. None


Correct Option: B
- Hide questions