J2EE Web Technologies - JSP, Servlets and JDBC

Test your knowledge of Java web development including JSP, Servlets, HTTP methods, MVC pattern, and basic JDBC transactions.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following are true ?

  1. The executeUpdate method returns all the rows that were affected
  2. The executeUpdate method returns the no. of rows that were affected
  3. Depends , as there is more than one version of this method with different return types
  4. NONE
Question 2 Multiple Choice (Single Answer)

Which of the following is false wrt Transactions ?

  1. A transaction is a set of sql statements
  2. Auto commit to be set off before Transaction
  3. Auto commit to be set off after transaction
  4. Commit permanently records to database all changes waiting with current Connection
  5. Rollback is used in case of any error to undo transaction
Question 3 Multiple Choice (Single Answer)

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…)
Question 4 Multiple Choice (Single Answer)

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
Question 5 Multiple Choice (Single Answer)

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
Question 6 Multiple Choice (Single Answer)

What are the life-cycle methods of JSP?

  1. jspInit(), _jspService() & jspDestroy()
  2. init(), service(), destroy()
  3. both 1&2
  4. none
Question 7 Multiple Choice (Single Answer)

What is the role of JSP in MVC Model?

  1. View
  2. Model
  3. Controller
  4. none
Question 8 Multiple Choice (Single Answer)

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
Question 9 Multiple Choice (Single Answer)

Which are the J2EE clients in the bleow?

  1. Applets
  2. Web Browsers
  3. Wireless clients.
  4. All the above
Question 10 True/False

Can we have pure java code inside JSP

  1. True
  2. False
Question 11 True/False

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

  1. True
  2. False
Question 12 True/False

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

  1. True
  2. False
Question 13 True/False

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

  1. True
  2. False
Question 14 Multiple Choice (Single Answer)

Can we write a constructor for servlet?

  1. Yes, but always call the default constructor.
  2. No, no need to call the default constructor.
  3. yes, always.
  4. no, always.
Question 15 Multiple Choice (Single Answer)

What are the different scopes available?

  1. page, request & session
  2. page, request & application.
  3. page, request, session & application.
  4. request, session & application.
Question 16 Multiple Choice (Single Answer)

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
Question 17 Multiple Choice (Single Answer)

Which are implicit objects in a JSP?

  1. only request, response
  2. only request, response & application
  3. request, response, session & application
  4. none
Question 18 Multiple Choice (Single Answer)

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
Question 19 True/False

A servlet instance (object) is created during the execution of JSP.

  1. True
  2. False
Question 20 Multiple Choice (Single Answer)

which xml file is been used by Web Container as a deployment descriptor to deploy Web Applications?

  1. ejb-jar.xml
  2. Can be any valid xml containing Web Module name
  3. web.xml
  4. config.xml