1)List out different layout in java.
Ans: Grid layout, flow layout, Border layout, GridBag layout
2) Explain the use of socket class.
Ans:
3) List four events of mouse.
Ans: mouseClicked(), mouseEntered(), mouseExited(), mousePressed(), mouseReleased(),
mouseDragged(), mouseMoved().
4) Explain PreparedStatement interface.
Ans: The PreparedStatement interface in Java is part of the java.sql package and is used to execute
parameterized SQL queries efficiently and securely in JDBC (Java Database Connectivity).
PreparedStatement ps = connection.prepareStatement("SQL query with ? placeholders");
5)Explain driver manager class.
Ans: DriverManager is a class in the java.sql package that manages a list of database drivers and
establishes a connection between a Java application and a database. It provides the getConnection()
method to connect to the database using a URL, username, and password.
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "user",
"password");
6) Define protocol.Enlist any two protocols.
Ans: In Java, a protocol refers to the communication rules used by the java.net package to connect
and communicate over a network. It is often specified in a URL to indicate how the connection
should be made.
List: HTTP, HTTPS, FTP, File, Jar, TCP/IP,UDP.
7) Compare JDBC and ODBC.
8) Differentiate between AWT and swing.
9)WAP to retrieve hostname using methods in InetAddress
class.
Ans:
10) WAP to demonstrate grid layout.
11) Explain some functions of Statement interface.
Ans:
12) Describe the JDBC architecture with the help of diagram.
Ans: JDBC (Java Database Connectivity) is an API that allows Java applications to interact with
databases using SQL.
Components of JDBC Architecture:
1. Java Application – Initiates database operations using JDBC.
2. JDBC API – Contains classes and interfaces like DriverManager, Connection, Statement, etc.
3. JDBC Driver Manager – Loads the appropriate JDBC driver and manages connections.
4. JDBC Driver – Translates JDBC calls into database-specific calls.
5. Database – Stores and processes data.
Types of JDBC Architecture:
1. Two-tier Architecture:
o Java application communicates directly with the database using JDBC.
o Simple but tightly coupled.
2. Three-tier Architecture:
o Java application communicates with a middle-tier (like a web server), which then
accesses the database.
o More scalable and secure.
14) WAP to create menu bar with various menu items and submenu items and also create
checkable menu item. On clicking a menu item display a suitable Dialog box.