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.
Questions
Which of the following are true ?
- The executeUpdate method returns all the rows that were affected
- The executeUpdate method returns the no. of rows that were affected
- Depends , as there is more than one version of this method with different return types
- NONE
Which of the following is false wrt Transactions ?
- A transaction is a set of sql statements
- Auto commit to be set off before Transaction
- Auto commit to be set off after transaction
- Commit permanently records to database all changes waiting with current Connection
- Rollback is used in case of any error to undo transaction
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?
- Static void doCalc(int x, int… args) {}
- Static void doCalc(int… args, int x) {}
- Static void doCalc(int[] args)
- Static void doCalc(int args…)
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
- 5
- 6
- Compile error
- Runtime error
Identify the advantages of JSP over Servlet.
- Embedding of Java code in HTML pages
- Platform independence
- Creation of database-driven Web applications
- Server-side programming capabilities
What are the life-cycle methods of JSP?
- jspInit(), _jspService() & jspDestroy()
- init(), service(), destroy()
- both 1&2
- none
What is the role of JSP in MVC Model?
- View
- Model
- Controller
- none
What do you understand by JSP translation?
- Parsing JSP using an XML Parser.
- Converting JSP into static Html content.
- Generating Servlet Code for the Jsp
- none
Which are the J2EE clients in the bleow?
- Applets
- Web Browsers
- Wireless clients.
- All the above
Can we have pure java code inside JSP
- True
- False
Every Custom Servlet extends javax.servlet.http.HttpServlet class
- True
- False
Web container translates JSP to Servlet for every request of the JSP
- True
- False
A JSP page can include another JSP page but not an HTML page
- True
- False
Can we write a constructor for servlet?
- Yes, but always call the default constructor.
- No, no need to call the default constructor.
- yes, always.
- no, always.
What are the different scopes available?
- page, request & session
- page, request & application.
- page, request, session & application.
- request, session & application.
Which statement below is true?
- ServletContext gives information about Container
- ServletContext gives information about Request
- ServletContext gives information about Session
- none
Which are implicit objects in a JSP?
- only request, response
- only request, response & application
- request, response, session & application
- none
Difference between GET & POST method. (Choose the right answer)
- Query length is limited in POST, not limited in GET.
- POST is secured whereas data is been submitted as part of URL in GET (not secured).
- By using POST method, we cannot submit the form.
- none
A servlet instance (object) is created during the execution of JSP.
- True
- False
which xml file is been used by Web Container as a deployment descriptor to deploy Web Applications?
- ejb-jar.xml
- Can be any valid xml containing Web Module name
- web.xml
- config.xml