Java Web Programming: Servlets, MVC, and Struts

Test your knowledge of Java web development including Servlets, JSP, MVC architecture patterns, and the Struts framework.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Given: 11. int i = 1,j = 10; 12. do { 13. if(i>j) { 14. break; 15. } 16. j--; 17. } while (++i <5); 18. System.out.println(“i =” +i+” and j = “+j); What is the result?

  1. i = 6 and j = 5
  2. i = 5 and j = 5
  3. i = 5 and j = 6
  4. i = 6 and j = 4
Question 2 Multiple Choice (Single Answer)

You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?

  1. default access
  2. public
  3. private
  4. protected
Question 3 Multiple Choice (Single Answer)

Given: 11. int x = 3; 12. int y = 1; 13. if (x = y) { 14. System.out.println(“x = “ + x); 15. } What is the result?

  1. x = 1
  2. x = 3
  3. Compilation fails.
  4. An exception is thrown at runtime.
Question 4 Multiple Choice (Single Answer)
  1. package test1; 2. public class Test1 { 3. static int x = 42; 4. } 1. package test2; 2. public class Test2 extends test1.Test1 { 3. public static void main(String[] args) { 4. System.out.println(“x = “ + x); 5. } 6. } What is the result?
  1. Compilation fails because of an error in line 2 of class Test2.
  2. x = 42
  3. Compilation fails because of an error in line 3 of class Test1.
  4. Compilation fails because of an error in line 4 of class Test2.
Question 5 Multiple Choice (Single Answer)

Given: 1. public class Delta { 2. static boolean foo(char c) { 3. System.out.print(c); 4. return true; 5. } 6. public static void main( String[] argv ) { 7. int i =0; 8. for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){ 9. i++ ; 10. foo(‘D’); 12. } 13. } 14. } What is the result?

  1. ABDCBDCB
  2. ABCDABCD
  3. Compilation fails.
  4. An exception is thrown at runtime.
Question 6 Multiple Choice (Multiple Answers)

what are the various types of Reporting

  1. Classical report
  2. Interactive report
  3. List and Grid display
  4. Style report
  5. General Report
Question 7 Multiple Choice (Single Answer)

core class of the Struts Framework

  1. ActionServlet
  2. ActionJsp
  3. ActionClass
  4. Action
Question 8 Multiple Choice (Single Answer)

What are the drawbacks of Struts?

  1. backword overflow
  2. forward overflow
  3. Single controller servlet
  4. no forward overflow
Question 9 True/False

A controller is the link between a user and the system.

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

Expansion of MVC architecture

  1. Model,Vision,Controller
  2. Medium,Vision,controller
  3. Model,View,Controller
  4. Model,View,Concept
Question 11 Multiple Choice (Single Answer)

Struts framework is based on ---- architeture

  1. MVS
  2. MVC1
  3. MVC
  4. MVC2
Question 12 Multiple Choice (Single Answer)

MVC1 architecture is

  1. loosely coupled
  2. not coupled
  3. tightly coupled
  4. coupled
Question 13 Multiple Choice (Single Answer)

The model component includes

  1. Bean
  2. HTML
  3. servlet
  4. jsp
Question 14 Multiple Choice (Single Answer)

The View part of MVC includes

  1. bean
  2. EJB
  3. JSP
  4. Servlet
Question 15 Multiple Choice (Single Answer)

The controller part includes

  1. Html
  2. jsp
  3. Servlet
  4. Bean
Question 16 True/False

In MVC2 flow is controlled by single servlet

  1. True
  2. False
Question 17 Multiple Choice (Multiple Answers)

Advantages of MVC

  1. Reusable
  2. Expressive
  3. not easy to use
  4. Easier support
Question 18 Multiple Choice (Single Answer)

What are Cookies

  1. information sent by web server
  2. information sent by servlet
  3. information sent by browser
  4. information sent by jsp
Question 19 Multiple Choice (Single Answer)

Method by which sensitive data is sent?

  1. doPost
  2. doGet
  3. Get
  4. Post
Question 20 Multiple Choice (Single Answer)

How do I send email from my Servlet?

  1. Mail Service
  2. Simple Mail Protocol
  3. Java Mail Service
  4. Mail Protocol