0% found this document useful (0 votes)
105 views7 pages

Advanced Java Exam Question Bank

This document is a question bank for the B.Sc. Part III Semester VI examination in Advanced Java at Shivaji University, Kolhapur, for March 2022. It includes multiple-choice questions covering topics such as JDBC, servlet life cycle, JSP, and Swing components, as well as descriptive questions for deeper understanding. The document serves as a study guide for students preparing for their examination in Computer Science.

Uploaded by

sankettippe9766
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views7 pages

Advanced Java Exam Question Bank

This document is a question bank for the B.Sc. Part III Semester VI examination in Advanced Java at Shivaji University, Kolhapur, for March 2022. It includes multiple-choice questions covering topics such as JDBC, servlet life cycle, JSP, and Swing components, as well as descriptive questions for deeper understanding. The document serves as a study guide for students preparing for their examination in Computer Science.

Uploaded by

sankettippe9766
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Shivaji University, Kolhapur

Question Bank for March 2022 (Summer) Examination


[Link]. Part – III Semester – VI (CBCS)
Computer Science Paper – XIII
Advanced Java
Subject Code: 81716

1) Which of the following option leads to the portability and security of Java?
i) The applet makes the Java code secure and portable
ii) Bytecode is executed by JVM
iii) Use of exception handling
iv) Dynamic binding between objects

2) What are the major components of the JDBC?


i) DriverManager, Statement, and ResultSet
ii) DriverManager, Driver, Connection, and Statement
iii) DriverManager, Connection, Statement, and ResultSet
iv) DriverManager, Driver, Connection, Statement, and ResultSet

3) Which is responsible for getting a connection to the database?


i) Driver ii) Connection
iii) Statement iv) ResultSet

4) Which package is used for importing swing components?


i) [Link] ii) [Link]
iii) [Link] iv) All of these

5) Which of the following is/are steps for the servlet life cycle?
i) Servlet class is loaded ii) Servlet instance is created
iii) init,Service,destroy method is invoked iv) All of these

6) Identify the method which is used to start a server thread.


i) start thread() ii) run()
iii) runthread() iv) start()

7) JDBC is __________
i) Java Database Communications ii) Java Database Concepts
iii) Java Database Connectivity iv) Java Database Connections
8) Which of the following displays components row-by-row in the order in which
they were added to the JFrame?
i) CardLayout ii) FlowLayout
iii) BorderLayout iv)GridLayout

9) The __________ class is used to display the tree structured data


i) JTable ii) JMenu
iii) JTree iv) JSlider

10) Method __________ class object is get called when button is clicked.
i) MouseEvent ii) KeyEvent
iii) ItemEvent iv) ActionEvent

11) Syntax of jsp declaration tag is______


i) <% %> ii) <%= %>
iii) <%! %> iv) <# #>

12) Change in the state of an object is known as___________ .


i) Event ii) listener
iii) Layout iv) application

13) Which of the following interface is used to execute parameterized queries?


i) Statement interface ii) PreparedStatement
iii) ResultSet interface iv) CallableStatement

14) JSP stands for?


i) Java server Pages ii)Java sequence pages
iii) Java standard Pages iv) None of these

15) Which http method sends by browser that asks the server to get the page
only?
i)get ii) put
iii)post iv) option

16) Which of the following package is used in JDBC programming?


i) [Link] ii) [Link]
iii) [Link] iv) [Link]

17) Which of the following is not an implicit object of JSP?


i) Out ii) Request
iii) Page iv) Cookie
18) Swing classes are present in _______.
i) [Link] ii) [Link]
iii) [Link] iv) [Link]

19) ____________ method of Statement interface is used to execute specified


query, it may be create, drop, insert, update, delete etc.
i) execute()
ii) executeUpdate()
iii) executeQuery()
iv) executeBatch()

20) ________ resides on server side.


i) Cookies
ii) web page
iii) Servlet
iv) session

21) Which interface provides object to store data fetched by queries from
database?
i) Statement
ii) ResultSet
iii) Connection
iv) None of these

22) Cookies are resides on __________ .


i) web container
ii) server side
iii) client side
iv) none of these

23) In Swing , ___________ class allows the editing of multiple line text.
i) JList
ii) JTextArea
iii) JCheckBox
iv) JTree

24) A ___________is a small piece of information that is persisted between the


multiple client requests.
i) Servlet ii)Table
ii) Cookie iv) URL
25)MVC stands for _________________________
i) Mode View Controller ii) Model View Control
iii) Model View Controller iv) Machine View Controller

26) What is the name of the Swing class that is used for frames?
i) Window ii) Frame
iii) JFrame iv) SwingFrame

27) To create swing components, which of the following is imported?


i) [Link].*; ii) [Link].*;
iii) [Link].*; iv) [Link].*;

28) Swing elements are preceded by the letter __________.


i) S ii) M
iii) J iv) P

29) The life cycle of a servlet is managed by ________________.


i) servlet context ii) servlet container
iii) servlet protocol iv) None of these

30) Which of the following are the life cycle method of jsp?
i) jspInit() ii) _jspService()
iii) jspDestroy() iv) All of these

31) Request processing of JSP is done by calling which method?


i) jspInit() ii) _jspService()
iii) jspDestroy() iv) _jspRequest()

32) Which of the following method helps in jsp page initialization?


i) jspInit() ii) _jspService()
iii) jspDestroy() iv) _jspRequest()

33) “Request” is instance of which one of the following classes?


i) Request ii) HttpRequest
iii) HttpServletRequest iv) ServletRequest

34) Which is not a directive?


i) include ii) page
iii) export iv) taglib
35) Which object of HttpSession can be used to view and manipulate
information about a session?
i) session identifier ii)creation time
iii) last accessed time iv) All of these

36) SWING components are_____.


i) Platform dependent ii) heavy weight
iii)Platform independent iv)both (i) & (ii)

37) Cookies are stored on __________ side.


i) server ii)client
iii)both (i) & (ii) iv)none of these

38) In Swing, ____________ class is used to display data in tabular form.


i)JList ii) JMenu
iii) JTable iv)JTextArea

39) ____________ are session tracking techniques.


i)URL rewriting ii) Hidden Form Field
iii) Cookies iv)All of these

40) Which is passive swing control that does not support any interaction with the
user?
i)JChoice ii)JLabel
iii) JList iv)JButton

Q.2) Attempt any two of the following. [16]


1) Explain Connection, Statement and ResultSet interfaces of JDBC API.
2) Explain different session management techniques in servlet.
3) Explain different components of swing with example.
4) What is JDBC? Explain in detail the process of JDBC.
5) Explain servlet communication in detail.
6) Explain in detail Life cycle of servlet.
7) What is JDBC? Explain JDBC connection steps with simple example.
8) Explain any four components of swing.
9) What is JSP? Explain different scripting elements of JSP.
10) Explain Session tracking technique in servlet.
11) Explain different JDBC drivers in detail.
12) Explain Connection, Statement and ResultSet interfaces of JDBC API.
13) What is JDBC? Explain JDBC connection steps with simple example.
14) Explain Java Database Connectivity with MySQL.
15) Explain any four components of swing.

Q.3) Attempt any four of the following. [16]


1) Write short note on JSP.
2) What is cookie? Explain two types of cookies.
3) Explain any JCheckbox and JRadioButton components in swing.
4) Explain life cycle servlet.
5) Write short note on LayoutManager class.
6) Explain JDBC connection steps.
7) What is JSP? Explain JSP life cycle
8) Differentiate between Servlet and JSP.
9) Explain in detail MVC architecture.
10) Write a note on ServletConfig.
11) Write a note on Servlet API.
12) Differentiate between AWT and Swing
13) Write short note on LayoutManager class.
14) Explain two swing components: JList and JComboBox
15) Explain life cycle of JSP.
16) Explain Statement interface of JDBC API.
17) Differentiate between Servlet and JSP.
18) Write short note on servlet. Write short note on JSP.
19) Write short note on servlet.
20) Explain session management using HttpSession.
21) Explain session management usingURLRewritting.
22) What is cookie? Explain two types of cookies.
23) Differentiate between doGet() and dopost()

24) Explain life cycle of Servlet.


25) Differentiate between Servlet and JSP.
26) Write short note on LayoutManager class.

27) Write short note on FlowLayout class.

28) Explain two swing components:

i) JList
ii) JComboBox.

29) Explain JCheckBox and JRadioButton in brief.

30) Write short note on cookies.

Common questions

Powered by AI

The servlet lifecycle is managed by a servlet container and involves three primary stages: initialization, servicing, and destruction. During initialization, the servlet container loads the servlet class and creates an instance of it, followed by calling the init() method. This prepares the servlet to handle requests. In the servicing phase, the servlet handles client requests through the service() method, which is invoked for each request. Finally, in the destruction phase, the servlet's destroy() method is called, allowing it to release resources before being garbage collected. These stages ensure efficient resource management and request handling in web applications .

Session management in Java Servlets enhances user experience by maintaining a user's state across multiple HTTP requests. It provides continuity, allowing data such as user preferences and shopping cart contents to persist across sessions. For security, session management mitigates issues related to statelessness of HTTP by securely tracking user activities with session IDs, which can include measures such as encryption and secure, HttpOnly flags to prevent interception and replay attacks. Techniques like URL rewriting, cookies, and HttpSession API are used to manage sessions securely, maintaining data integrity and protecting against unauthorized access .

The process of establishing a database connection using JDBC involves several components. First, the DriverManager is used to load the appropriate driver using a class method typically called Class.forName. Once the driver is loaded, a Connection object is obtained from DriverManager.getConnection by providing the database URL, username, and password. This Connection object will be used to create a Statement object, which allows you to execute queries. The results of these queries are obtained through a ResultSet object, facilitating data extraction from the database. These components - DriverManager, Connection, Statement, and ResultSet - are crucial for the seamless interaction between Java applications and databases .

The PreparedStatement interface in JDBC enhances query execution by allowing precompiled SQL statements, which optimize performance and improve security compared to the Statement interface. Unlike Statement objects, PreparedStatements can efficiently handle dynamic parameters through parameterized queries, reducing the risk of SQL injection. This interface also manages SQL execution on the database server side rather than compiling each time a statement is executed, significantly boosting performance for repeated queries. Since PreparedStatements are precompiled, they also facilitate cleaner and more readable code by abstracting SQL parameterization .

The Model-View-Controller (MVC) architecture in Java web development separates an application into three interconnected components. The model represents the data and business logic, encapsulating the core functionality of the application. The view is responsible for displaying the data from the model to the user, ensuring a dynamic user interface. The controller acts as an intermediary, handling user input and updating both the model and view. This separation of concerns facilitates modular development, improves scalability, and enhances maintainability by allowing developers to work on individual components without affecting others .

JDBC drivers can be categorized into four types, each suited for different scenarios. Type 1 drivers, or JDBC-ODBC bridge drivers, are now largely obsolete, acting as a bridge between JDBC calls and an ODBC driver. Type 2 drivers are native-API drivers that convert JDBC calls into native code of the client API. They are more efficient than Type 1 but require native libraries. Type 3 drivers, or network protocol drivers, translate JDBC calls into a database-independent network protocol, offering a server-based solution. Type 4 drivers, or thin drivers, directly convert JDBC calls into the vendor-specific database protocol, providing a direct connection without the need for native libraries, and are most commonly used today for their ease and efficiency .

Swing is a lightweight, platform-independent GUI toolkit that is built on top of AWT. While AWT components are heavyweight and dependent on the native system's graphical systems, Swing offers greater flexibility and better cross-platform functionality due to its implementation in pure Java. Swing components, prefixed with 'J' such as JFrame, JPanel, and JButton, support complex GUI features like pluggable look and feel, model-view-controller architecture, and rich text handling. However, it generally requires more memory and can be slower than AWT. AWT is suitable for simpler applications where direct access to native system components is advantageous, while Swing is preferred for more feature-rich and consistent user interfaces across platforms .

FlowLayout in Java Swing is a layout manager that positions components in a left-to-right flow, similar to lines of text in a paragraph, wrapping them as necessary to fit within the container. It is the default layout manager for JPanel and is used for simple GUIs where the order of components is important, for example, small toolbars or simple input forms. The alignment can be adjusted (left, center, or right) to manage spaces between components, but it does not support resizing; hence it is more suited for applications with a known, fixed size of components. FlowLayout is simple and effective for laid-back designs without complex alignment requirements .

JSP directives provide global information for the entire JSP page and affect the structure and properties of the generated servlet. Examples include the use of the page directive to set properties such as language and session, the taglib directive to define tag libraries, and the include directive to include files during translation time. In contrast, JSP scripting elements are fragments of Java code within the JSP page, which are inserted directly into the servlet's service method. These include expressions, scriptlets, and declarations, allowing dynamic content generation. While directives influence the setup and configuration of the JSP page at a more fundamental level, scripting elements modify the logic and output within the execution of requests .

Java's main advantage of portability and security is achieved through the use of bytecode and the Java Virtual Machine (JVM). Bytecode allows Java programs to be executed on any platform that has a JVM, making Java applications platform-independent. The JVM executes this bytecode, providing an additional layer of security by encapsulating and managing execution processes. This setup ensures that Java code can be written once and run anywhere, enhancing both its portability and security by preventing platform-specific vulnerabilities .

You might also like