Java Web Programming: Servlets, MVC, and Struts
Test your knowledge of Java web development including Servlets, JSP, MVC architecture patterns, and the Struts framework.
Questions
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?
- i = 6 and j = 5
- i = 5 and j = 5
- i = 5 and j = 6
- i = 6 and j = 4
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?
- default access
- public
- private
- protected
Given: 11. int x = 3; 12. int y = 1; 13. if (x = y) { 14. System.out.println(“x = “ + x); 15. } What is the result?
- x = 1
- x = 3
- Compilation fails.
- An exception is thrown at runtime.
- 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?
- Compilation fails because of an error in line 2 of class Test2.
- x = 42
- Compilation fails because of an error in line 3 of class Test1.
- Compilation fails because of an error in line 4 of class Test2.
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?
- ABDCBDCB
- ABCDABCD
- Compilation fails.
- An exception is thrown at runtime.
what are the various types of Reporting
- Classical report
- Interactive report
- List and Grid display
- Style report
- General Report
core class of the Struts Framework
- ActionServlet
- ActionJsp
- ActionClass
- Action
What are the drawbacks of Struts?
- backword overflow
- forward overflow
- Single controller servlet
- no forward overflow
A controller is the link between a user and the system.
- True
- False
Expansion of MVC architecture
- Model,Vision,Controller
- Medium,Vision,controller
- Model,View,Controller
- Model,View,Concept
Struts framework is based on ---- architeture
- MVS
- MVC1
- MVC
- MVC2
MVC1 architecture is
- loosely coupled
- not coupled
- tightly coupled
- coupled
The model component includes
- Bean
- HTML
- servlet
- jsp
The View part of MVC includes
- bean
- EJB
- JSP
- Servlet
The controller part includes
- Html
- jsp
- Servlet
- Bean
In MVC2 flow is controlled by single servlet
- True
- False
Advantages of MVC
- Reusable
- Expressive
- not easy to use
- Easier support
What are Cookies
- information sent by web server
- information sent by servlet
- information sent by browser
- information sent by jsp
Method by which sensitive data is sent?
- doPost
- doGet
- Get
- Post
How do I send email from my Servlet?
- Mail Service
- Simple Mail Protocol
- Java Mail Service
- Mail Protocol