0% found this document useful (0 votes)
14 views8 pages

Ajp (1) With Probable Answer

The document covers various topics in Java programming, focusing on event handling, networking basics, and interacting with databases. It includes multiple-choice questions related to event listeners, socket communication, and JDBC concepts. Each section provides insights into specific Java classes and interfaces used for handling events, network connections, and database interactions.

Uploaded by

raneshravani628
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)
14 views8 pages

Ajp (1) With Probable Answer

The document covers various topics in Java programming, focusing on event handling, networking basics, and interacting with databases. It includes multiple-choice questions related to event listeners, socket communication, and JDBC concepts. Each section provides insights into specific Java classes and interfaces used for handling events, network connections, and database interactions.

Uploaded by

raneshravani628
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
You are on page 1/ 8

Unit III - Event Handling

1. What is the main purpose of the delegation event model in event-driven


programming?

o A) To allow event listeners to manage multiple events

o B) To separate event source and event handling

o C) To create a single event listener for all components

o D) To handle events in a sequential manner

2. Which of the following is an event listener interface in Java?

o A) EventListenerInterface

o B) ActionListener

o C) ComponentListener

o D) EventHandlerInterface

3. In the delegation event model, who is responsible for handling an event?

o A) Event source

o B) Event listener

o C) Event object

o D) Event handler

4. Which class in Java is used to represent a mouse event?

o A) MouseEvent

o B) MouseListener

o C) KeyEvent

o D) ButtonEvent

5. What is the primary function of an Adapter class in Java?

o A) To handle multiple types of events

o B) To implement default methods for event interfaces

o C) To convert events to a format suitable for event listeners

o D) To allow multiple event listeners for a single event

6. Which interface must be implemented to handle action events in Java?

o A) ActionEventListener

o B) ActionListener

o C) ButtonListener
o D) ComponentListener

7. Which Java class is used for handling keyboard events?

o A) KeyEvent

o B) KeyboardListener

o C) ActionListener

o D) KeyPressListener

8. In Java, which event is generated when the user clicks on a button?

o A) ActionEvent

o B) MouseEvent

o C) ItemEvent

o D) WindowEvent

9. What type of event does the ItemEvent class handle?

o A) Button press

o B) Text input

o C) Checkbox or item selection

o D) Mouse click

10. Which of the following is an example of an inner class in Java?

o A) A class defined outside the main class

o B) A class declared within another class

o C) A class implemented using an interface

o D) A class that extends another class

11. What does the MouseMotionListener interface handle?

o A) Mouse clicks

o B) Mouse movement events

o C) Mouse scroll events

o D) Mouse dragging events

12. Which event is generated when the window is closed?

o A) ActionEvent

o B) WindowEvent

o C) KeyEvent

o D) MouseEvent
13. Which of the following is a type of event that the WindowListener interface
handles?

o A) WindowOpenedEvent

o B) MouseClickedEvent

o C) ActionPerformedEvent

o D) KeyTypedEvent

14. Which method is used to register an event listener for an ActionEvent in Java?

o A) addActionListener()

o B) registerListener()

o C) addListener()

o D) addEventListener()

15. What is the purpose of the TextListener interface in Java?

o A) To handle mouse events

o B) To handle text input events

o C) To handle key press events

o D) To handle window events

16. What type of event is generated by pressing a key on the keyboard?

o A) ActionEvent

o B) KeyEvent

o C) MouseEvent

o D) WindowEvent

17. Which of the following is a method in the ActionEvent class?

o A) getKeyCode()

o B) getSource()

o C) getMousePosition()

o D) getItemState()

18. What does the Adapter class in Java do?

o A) Implements all listener methods with empty bodies

o B) Registers event listeners for multiple event types

o C) Handles the event source

o D) Converts event data into a readable format


19. Which class in Java can be used to handle mouse dragging events?

o A) MouseMotionEvent

o B) MouseListener

o C) MouseEvent

o D) MouseAdapter

20. Which event listener interface is used to handle changes in a checkbox state?

o A) ActionListener

o B) ItemListener

o C) MouseListener

o D) TextListener

Unit IV - Networking Basics

21. Which Java class is used to retrieve the IP address of a given host name?

o A) InetAddress

o B) URLConnection

o C) Socket

o D) ServerSocket

22. Which class is used to manage the connection to a URL in Java?

o A) URL

o B) URLConnection

o C) InetAddress

o D) URLHandler

23. Which method in the URLConnection class is used to get input from a URL?

o A) getInputStream()

o B) getData()

o C) openStream()

o D) getOutputStream()

24. What is the main function of the InetAddress class in Java?

o A) To create a new socket connection

o B) To get information about a host's network address

o C) To handle URL connections


o D) To create a proxy server

25. In a TCP/IP communication, which method is used to bind a server socket to a


specific port?

o A) bind()

o B) listen()

o C) connect()

o D) setPort()

26. Which of the following Java classes are used for network communication via
TCP/IP?

o A) Socket, ServerSocket

o B) DatagramSocket, DatagramPacket

o C) URL, URLConnection

o D) InetAddress, DatagramSocket

27. What type of socket is used for Client/Server communication in Java?

o A) DatagramSocket

o B) Socket

o C) ServerSocket

o D) ProxySocket

28. What does the URL class represent in Java?

o A) A specific protocol for communication

o B) A Uniform Resource Locator (web address)

o C) A method for handling server requests

o D) A class for handling network sockets

29. What is the purpose of a Datagram Packet in Java networking?

o A) To store connection details of a socket

o B) To send data over a TCP/IP connection

o C) To represent a message sent via UDP

o D) To create a virtual connection between clients

30. Which protocol is used for connectionless communication in Java?

o A) TCP

o B) HTTP

o C) UDP
o D) FTP

31. What is the difference between a TCP socket and a UDP datagram in terms of
reliability?

o A) TCP is connectionless, while UDP is reliable

o B) TCP is slower but more reliable than UDP

o C) UDP guarantees message delivery, TCP does not

o D) TCP and UDP are equally reliable

32. Which class in Java is used for sending and receiving UDP datagrams?

o A) DatagramPacket

o B) DatagramSocket

o C) ServerSocket

o D) Socket

33. How does the DatagramSocket class communicate in Java?

o A) By using IP addresses and ports

o B) By establishing a TCP connection

o C) By using a fixed connection

o D) Through a secure communication protocol

34. What does the DatagramPacket class in Java represent?

o A) A network request message

o B) A packet of data to be sent over the network

o C) A server response

o D) A set of network parameters

35. Which of the following is an example of using TCP/IP in Java?

o A) URLConnection

o B) DatagramSocket

o C) ServerSocket, Socket

o D) ProxyServer

Unit V - Interacting with Databases

36. What is the primary difference between JDBC and ODBC?

o A) JDBC is for Java, ODBC is for all programming languages


o B) JDBC is faster than ODBC

o C) JDBC supports more databases than ODBC

o D) ODBC is a newer technology than JDBC

37. Which of the following is a JDBC driver type?

o A) Type 1, Type 2, Type 3, Type 4

o B) Type A, Type B, Type C, Type D

o C) Direct, Proxy, Open

o D) Native, Remote, Hybrid

38. What is the purpose of the DriverManager class in JDBC?

o A) To handle SQL exceptions

o B) To manage and load database drivers

o C) To execute SQL statements

o D) To maintain database connections

39. In the two-tier JDBC architecture, which component connects directly to the
database?

o A) Client

o B) Server

o C) Driver

o D) Database

40. What is the main advantage of using a three-tier JDBC architecture?

o A) Better security through client-server communication

o B) Simplified database management

o C) Reduced database load

o D) Scalability and separation of concerns

41. Which JDBC driver type requires the installation of a database client?

o A) Type 1

o B) Type 2

o C) Type 3

o D) Type 4

42. Which of the following is an example of using JDBC for database connectivity?

o A) Connecting to a database via a URL


o B) Using a direct connection to a database server

o C) Opening a client-side database connection

o D) Sending HTTP requests to a database server

43. Which JDBC method is used to establish a connection to the database?

o A) connect()

o B) openConnection()

o C) getConnection()

o D) createConnection()

44. What does the PreparedStatement interface in JDBC allow?

o A) Batch execution of SQL statements

o B) Sending HTTP requests to a database

o C) Dynamic retrieval of data from databases

o D) Execution of SQL queries with predefined parameters

45. What is the primary advantage of using a PreparedStatement over a Statement in


JDBC?

o A) PreparedStatement is slower

o B) PreparedStatement improves security by preventing SQL injection

o C) PreparedStatement does not support batch operations

o D) PreparedStatement is limited to SELECT queries

You might also like