combine
combine
POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR
2024-2025
4. Name the class which is used to create a port where the server will listen.
(a) Server (b) Socket (c) ServerSocket (d) SocketServer
10. In this constructor ServerSocket(int port, int max_queue) what is the default value for max_queue?
a. 100 b. 50 c. 75 d. 80
13. How many ports of TCP/IP are reserved for specific protocols?
a. 10 b. 1024 c. 2048 d. 512
17. Network programming in any language definitely needs to deal with____ and ____.
a. user names; port numbers b. IP addresses; link‐ layer address c. IP addresses; port numbers d. None of the choices are correct
18. The class used in Java network programming for socket address is the ____ class.
a. InetAddress b. Socket address c. InetSocketAddress d. None of the choices are correct
21. Which of these package contains classes and interfaces for networking?
A. java.io B. java.util C. java.net D. javax.swing
26. Which of the following method call is valid to obtain the server's hostname by invoking an applet?
A. getCodeBase().host() B. getCodeBase().getHost() C. getCodeBase().hostName() D. getCodeBase().getHostName()
27. The server listens for a connection request from a client using which of the following statement?
A. Socket s = new Socket(ServerName, port); B. Socket s = serverSocket.accept()
C. Socket s = serverSocket.getSocket() D. Socket s = new Socket(ServerName);
28. The client requests a connection to a server using which of the following statement?
A. Socket s = new Socket(ServerName, port);
B. Socket s = serverSocket.accept();
C. Socket s = serverSocket.getSocket();
D. Socket s = new Socket(ServerName);
29. To connect to a server running on the same machine with the client, which of the following cannotbe used for the
hostname?
30. A. “localhost” B. "127.0.0.1" C. InetAddress.getLocalHost() D. "127.0.0.0"
2
31. In the socket programming, for an IP address, which can be used to find the host name and IP address of a client/
server?
A. The ServerSocket class B. The Socket class C. The InetAddress class D. The Connection interface
31. To create an InputStream on a socket, say s, which of the following statement is necessary?
A. InputStream in = new InputStream(s); B. InputStream in = s.getInputStream();
C. InputStream in = s.obtainInputStream(); D. InputStream in = s.getStream();
32. Which of the following protocols is/are for splitting and sending packets to an address across a network?
A. TCP/IP B. FTP C. SMTP D. UDP
33. Which of the following type of JDBC driver, is also called Type 1 JDBC driver?
A. JDBC‐ODBC Bridge plus ODBC driver B. Native‐API, partly Java driver C. JDBC‐Net, pure Java driver D. Native‐protocol, pure
Java driver
35. Which of the following type of JDBC driver, is also called Type 2 JDBC driver?
A. JDBC‐ODBC Bridge plus ODBC driver B. Native‐API, partly Java driver C. JDBC‐Net, pure Java driver D. Native‐protocol,
pure Java driver
36. Which of the following holds data retrieved from a database after you execute an SQL query using Statement objects?
A. ResultSet B. JDBC driver C. Connection D. Statement
41. URL stands for Uniform Resource Locator and represents a resource on the World Wide Web, such as a Web page or FTP
directory.
A. True B. False
42 Which class is used to create servers that listen for either local client or remote client programs?
A. ServerSockets B. httpServer C. httpResponse D. None of the above
43. Which constructor of DatagramSocket class is used to creates a datagram socket and binds it with the given Port Number?
A. DatagramSocket(int port) B. DatagramSocket(int port, InetAddress address)
C. DatagramSocket() D. None of the above
3
46. Which method of URL class represents a URL and it has complete set of methods to manipulate URL in Java?
A. java.net.URL B. java.net.URLConnection C. Both A & B D. None of the above
49. The DatagramSocket and DatagramPacket classes are not used for connection‐less socket programming.
A. True B. False
52. Which of these method of DatagramPacket class is used to find the destination address?
(a) findAddress( ) (b) getAddress( ) (c) address( ) (d) whoIs( )
56. The URLConnection class can be used to read and write data to the specified resource
referred by the URL
a. True b. False
57. Datagram is basically an information but there is no guarantee of its content, arrival or
arrival time.
a. True b. False
60. The flush() method of PrintStream class flushes any uncleared buffers in memory
a. True b. False
61. Which method of ServerSocket will wait for a client to initiate communication and then communication with the client?
a. wait( ) b. connect( ) c. waitForClient( ) d. WaitForConnect( )
65. Which is the proper method to retrieve the host name of local machine?
a. static InetAddress getLocalHost( ) throws UnknownHostException
b. static InetAddress getByName(String host_name ) throws UnknownHostException
c. static InetAddress getAllByName(String host_name ) throws UnknownHostException
5
Sanjivani Rural Education Society’s
SANJIVANI K. B. P.
POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST:
AHMEDNAGAR
2024-2025
16. The Swing Component classes that are used in Encapsulates a mutually exclusive set of buttons?
a) AbstractButton b) ButtonGroup c) JButton d) ImageIcon
19. Which of the following architecture does the swing framework use ?
a) MVC b) MVP c) Layered Architecture d) Master-slave Architectur
a) JTable b) JTree
c) JToolTip d) None of the above
26. __________ is a Swing layout manager that arranges components in a row & a column.
a)BoxLayout b)GridLayout c)BorderLayout d)FlowLayout
31. Which component is display area for a short string of text, image or both?
a)Jbutton b)JLabel c)JTextfield d)JTextArea
36. Which of the following swing components do not have an Icon parameter in its constructor?
a)JTextField b)JTextArea c)Both a and b d)none of these
40. Which Swing component’s default layout manager arranges components in a top-to-bottom order?
a)JPanel b) JFrame c)JToolBar d) JScrollPane
42. Which swing component is used for inputting a single line of text
a)JLabel b)JTextArea c)JTextField d)JButton
48. When adding a JComponent to a container, which of these methods is called by default?
a)insert() b)append() c)put() d)add()
49. Which method call will NOT affect the size of a JFrame?
a)pack() b)setPrefferedSize() c)setSize() d)setBounds()
50. Which component automatically updates its display when its Model changes?
a)JTable b)JList c)JComboBox d)JTextArea
52. In which method is the Graphics object provided for painting in Swing?
a)paint() b)render() c)paintComponent() d)draw()
55. Which method should be used to remove all items from a JComboBox?
a)clear() b)reset() c)deleteAll() d)removeAllItems()
57. Which of the following is NOT a direct method to change a component’s foreground color?
a)setTextColor() b)setForeground c)setColor d)setPaintColor
60. What is the default behavior of JScrollPane when its viewport is empty?
a) Displays an empty scroll pane b)Shows a placeholder message.
c)Automatically hides itself. D) Throws an exception.
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR
2023-2024
1. Which of the following is the top-level interface for handling events in Java
a) EventListener b) EventObject c) ActionEvent d) WindowEvent
11. What is the return type of the getSource() methodl in event handling?
a) Object b) String c) int d) Event
12. Which interface is used to handle events related to items in a component like checkboxes?
a) ItemListener b) ActionListener c) KeyListener d) WindowListener
15. Which event occurs when a user presses and releases a key?
a) KeyPressed b) KeyReleased c) KeyTyped d) All of the above
16. Which class is used as a base class for all AWT events?
a) EventObject b) ActionEvent c) AWTEvent d) Event
19. Which of the following methods is used to remove an action listener from a button?
a) removeActionListener() b) deleteActionListener() c) unregisterActionListener()d) detachActionListener()
21. Which class is the base class for all event classes in Java?
a) EventObject b) AWTEvent c) ComponentEvent d) ActionEvent
23. Which method must be implemented when using the ActionListener interface?
a) actionPerformed() b) actionEvent() c) actionTriggered() d) performAction()
25. Which of the following is a valid event type for the MouseListener interface?
a) mouseClicked b) keyPressed c) componentResized d) windowClosed
26. What is the purpose of the mouseReleased method in the MouseListener interface?
a) To handle mouse button presses b) To handle mouse movements
c) To handle mouse button releases d) To handle mouse clicks
28. Which method in the WindowListener interface is called when a window is closed?
a) windowClosing b) windowClosed c) windowActivated d) windowDeactivated
35. Which method in the ActionEvent class retrieves the command string associated with the event?
a) getActionCommand() b) getCommand() c) retrieveCommand() d) getEventCommand()
36. Which method in the MouseAdapter class is used to handle mouse clicked events?
a) mouseClicked() b) mousePressed() c) mouseReleased() d) mouseEntered()
37. What is the default event handling model for Swing components?
a) Event delegation model b) Event broadcasting model c) Event handling model d) Event propagation model
38. Which class is used to create a graphical user interface window in Java Swing?
a) JFrame b) JPanel c) JWindow d) JFrameWindow
40. Which method in the ItemListener interface handles item state changes?
a) itemStateChanged() b) itemChanged() c) stateChanged() d) itemSelected()
42. Which method in the WindowAdapter class is called when a window is minimized?
a) windowIconified() b) windowMinimized() c) windowClosed() d) windowDeiconified()
45. Which class provides an implementation for the WindowListener interface in an adapter form?
a) WindowAdapter b) WindowHandler c) WindowListenerAdapter d) WindowEventAdapter
49. Which method in the MouseMotionListener interface is invoked when the mouse is dragged?
a) mouseDragged() b) mouseMoved() c) mousePressed() d) mouseReleased()
50. How can you listen for changes in the state of a checkbox in Swing?
a) Implement ItemListener and register it with the checkbox
b) Implement ActionListener and register it with the checkbox
c) Implement FocusListener and register it with the checkbox
d) Implement MouseListener and register it with the checkbox
Sanjivani Rural Education Society’s
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR
2023-2024
6.Runnable is
a) Class b) Method c) Variable d) Interface
7. Which collection class associates values with keys, and orders the keys according to their naturalorder
a) java.util.HashSet b) java.util.LinkedList c) java.util.TreeMap d) java.util.SortedSet
11. What does the following line of code do? TextField tf = new TextField(10);
(a) will set 10 to TextField as its initial text b) Will set the character capacity to 10
(c) Both A & B d) None of These
12. Frame is a standard window, which is of Window class from AWT hierarchy?
a) Derived class / Subclass b) Base class / Super class c) Root class d) Family class
18. Which of the following does not have its default layout as BorderLayout.
a) Frame b) Dialog c) JApplet d) All of Above
26. What is use of second parameter given in Label constructor : Label(String, int)
(a) Specifies height of label in terms of pixels
(b) specifies width of label in terms of pixels
27.Which of these classes can be added to any container class, using the add method defined incontainer
class?
a) Button b) CheckboxMenuItem c) Menu d)MenuBar
28.Which of the following methods can be used to change the size of a java.awt.Component object?
a) dimension() b) setSize() c) area() d) size()
29.Which of the following methods can be used to remove a java.awt.Component object from thedisplay?
a) disappear() b) delete() c) remove() d) hide()
30.These two ways are used to create a Frame
1.By creating the object of Frame class(association)2.By extending Frame class
(inheritance)
a)True b) False
31. The tittle of the frame can be set in AWT using the method.
a) setHeading b) setTitle c) createTitle d) settitle
32. Which are passive controls that do not support any interaction with the user?
a) Choice b) List
c) Labels c) Settitle
33.How Many ways can be align the label in a container?a) 1 b) 2
c) 3 d) 4
34. By which method we can set or change the text in a Label in AWT?
a) setText() b) getText() c) addText() d) all of these
39.Color class can create object of it using which of the following color values?
a) RGB b) RYB c) CMY d) HSB
44. The concept of Menu Bar can be implemented by using three java classes‐
a) Menu b) MenuBar c) MenuItem d) All of these
45. Which method is used to append the text at the end of TextArea?
a) append() b) add() c) appendAt() d) addAt()
46. The immediate super class of TextArea is
a) TextField b) TextBox c) TextComponent d) Component
47. Which is the container that doesn’t contain title bar and menu bars. It can have other componentslike button, text
field etc?
a) Window b) Frame c) Panel d) Container
48. Which object can be constructed to show any number of choices in the visible window?
a) Choice b) Menu c) List d) Checkbox
49. By which method we can set or change the text in a label in AWT?
a) setText() b) getText() c) addText() d) all of these
59. Which object can be constructed to show any number of choices in the visible window?
a) Label b) Choice c) List d) Checkbox
60. Which of the following class is derived from the container class?
a) Component b) Panel c) MenuComponent d) List
61. Give the abbreviation of AWT.
A.Applet Windowing Toolkit. B. Abstract Windowing Toolkit. C.Absolute Windowing Toolkit. D.Both A& B
62. Which is the container that contain title bar and can have MenuBars .it can have other component like Button
,textfield, etc ?
A. Panel B. Frame C. Window D. Container
63. Which is a component in AWT that can contain another components like button, textfield, labels, etc?
A. Window B. Container C. Panel D. Frame
66. These two ways are used to create a Frame By creating object of Frame class ( association ), By extending Frame
class ( inheritance ).
A. True B.False
67. Which is the container that doesn’t contain title bar and MenuBar. It can have components like button, textfield,
etc ?
A. Window B. Frame C. Panel D.Container
68. How many types of control does AWT supports these controls are subclasses of components
A. 7 B. 6 C. 5 D. 8
69. Which are passive controls that do not support any interaction with the user ?
A. Choice B. List C. Label D. Checkbox
70. By which method you can set or change the text in a label ?
A. setText() B. getText() C. Both A & B D. none of the above
71. Which class is used to create a pop – up list of items from which the user may choose ?
A. List B. Choice C. Labels D. CheckBox
72. Which object can be constructed to show any number of choices in the visible window ?
A. Labels B. Choice C. List D. CheckBox
73. Which is used to store data and partial result , as well as to perform dynamic linking , return values for methods ,
and dispatch exceptions ?
A. Window B. Panel C. Frame D. Container
74. The following way is used to create a frame is by creating the object of frame class ?
A. Inheritance B. association C. Both A & B D. none of above
75. AWT more powerful components like table ,list, scroll panes, color chooser, tabbed pane ?
A. True B. False
Sanjivani Rural Education Society’s
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR / 63
2023-2024
Sub Name : Advanced Java Programming (AJP-22517) Course Code : CM-5-I
Name : Date: / /2023
Roll No : Set: II
Practice Test: [ Unit V- Interacting with Database]
10. Which of the following is not a valid SQL data type in JDBC?
a) VARCHAR b) INT c) DOUBLE d) BOOLEAN
12. In JDBC, which exception is thrown when there is a problem with the SQL syntax?
a) SQLException b) SQLSyntaxException c) SQLQueryException d) SyntaxError
13. Which method is used to execute a query in JDBC and retrieve the results in a `ResultSet`?
a) executeQuery() b) executeUpdate() c) execute() d) executeBatch()
26. The package contains classes that help in connecting to a database, sending SQL statements to the database and process
the query request.
(a)connection.sql (b)b.sql (c)pkg.sql (d)java.sql
28.In JDBC imports all Java classes that are concern with Database connectivity.
(a) javax.sql (b)java.mysql (c)java.sql (d)com.sql
30.In the below statement, which type of query can be used with executeUpdate() method. statement.executeUpdate(query here)
(a)Insert, Update, Delete (b)Insert, Select, Delete (c)Only Select (d) Any Query
34. Identify the isolation level the prevents the dirty in the JDBC connection class?
a) TRANSACTION_READABLE_READ
b) TRANSACTION_READ_COMMITED
c) TRANSACTION_READ_UNCOMMITED
d) TRANSACTION_NONE
35. In order to transfer data between a database and an application written in the Java programming language, the JDBC API
provides which of these methods?
a. Methods on the ResultSet class for retrieving SQL SELECT results as Java types.
b. Methods on the PreparedStatement class for sending Java types as SQL statement parameters.
c. Methods on the CallableStatement class for retrieving SQL OUT parameters as Java types.
d. All mentioned above
36. The JDBC API has always supported persistent storage of objects defined in the Java programming language through the
methods getObject and setObject.
a. True b. False
37.Which JDBC type represents a "single precision" floating point number that supports seven digits of mantissa?
a. REAL b. DOUBLE c. FLOAT d. INTEGER
38. Which method is used for retrieving streams of both ASCII and Unicode characters is new in the JDBC 2.0 core API?
a. getCharacterStream b. getBinaryStream c. getAsciiStream d. getUnicodeStream
39. How many Result sets available with the JDBC 2.0 core API?
a. 2 b. 3 c. 4 d. 5
41. The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.
a. True b. False
42. Which method Drops all changes made since the previous commit/rollback?
a. public void rollback() b. public void commit()
c. public void close() d. public Statement createStatement()
43. The intent is for JDBC drivers to implement nonscrollable result sets using the support provided by the underlying database
systems.
a. True b. False
44. Which methods returns a stream that simply provides the raw bytes from the database without any conversion?
a. getCharacterStream b. getBinaryStream c. getAsciiStream d. getUnicodeStream
49. Which JDBC driver types can you use in a three-tier architecture and if the web server and the DBMS are running on the same
machine.
a)Type 1 b)Type 2 c)Type 3 and 4 d)Type 1, Type 2, Type 3 and Type 4
50. Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the
DBMS server?
a)JDBC-NET b)JDBC-ODBC Bridge c)Native api as basis d)native protocol as basis
59. Which of the following describes the correct sequence of the steps involved in making a connection with a database.
1. Loading the driver 2. Process the results.
3. Making the connection with the database. 4. Executing the SQL statements.
A. 1,3,4,2 B. 1,2,3,4 C. 2,1,3,4 D. 4,1,2,3
60. All raw data types (including binary documents or images) should be read and uploaded to the database as an array of
a. byte b. int c. Boolean d. char
62. Which statement type is used to execute SQL queries that do not return results, such as INSERT, UPDATE, and DELETE
statements?
A. PreparedStatement B. Statement
17. Which Swing component is best for displaying multiple lines of text?
a) JLabel b) JTextField c) JTextArea d) JButton
22. Which of the following correctly instantiates a JFrame with the title "MyApp" and sets its close operation?
a) JFrame frame = new JFrame(); frame.setTitle("MyApp"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b) JFrame frame = new JFrame("MyApp"); frame.setCloseOperation(JFrame.EXIT_ON_CLOSE);
c) JFrame frame = new JFrame("MyApp"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
d) JFrame frame = new JFrame("MyApp"); frame.setVisible(true);
23. A JFrame cannot contain more than one JPanel at a time. a) True b) False
27. A JButton can have both an icon and text at the same time. a) True b) False
28. Which method is used to get the selected item from a JComboBox?
a) getText() b) getSelectedItem ()c) getSelection() d) getSelected()
30. The setPreferredSize() method guarantees the final size of a JComponent. a) True b) False
32. What will happen if setVisible(true) is not called for a JFrame object?
a) The frame will be visible. b) The frame will not be created.
c) The frame will be created but not visible. d) The frame will throw an exception.
34. Which of the following is responsible for handling events in a Swing application?
a) JComponent b) JFrame c) Event Queue d) ActionListener
38. If you forget to call super.paintComponent(g) in the paintComponent() method of a JPanel, what will happen?
a) Nothing b) The background may not be cleared properly
c) The panel will not be displayed d) The application will crash
40. Which of the following is responsible for handling events in a Swing application?
a) JComponent b) JFrame c) Event Queue d) ActionListener
42. Which method is used to set the position and size of a JComponent?
a) setBounds() b) setPosition() c) setLayout() d) setFrame()
43. What is the output of the following code?
JFrame frame = new JFrame();
frame.setSize(300, 300); a) A frame of size 300x300 is visible. b) A frame is visible but its size is undefined.
frame.setVisible(true); c) Nothing happens. d) A frame appears but its content is not visible
45. Find the missing statement: To add a menu bar to a JFrame, use ______.
a)frame.setComponent(menuBar) b) frame.add(menuBar)
c) frame.setMenu(menuBar) d) frame.setJMenuBar(menuBar)
47. What will be the output if a JTextField has a width of 10 but is set with text of 20 characters?
a) The text will be truncated. b) The text will automatically scroll.
c) An exception will occur. d) The text will be completely visible.
48. What will be the output of the following code? a) The button will be placed at the center of the panel.
JPanel panel = new JPanel(); b) The button will be placed at the left side of the panel.
panel.add(new JButton("Click")); c) The button will not be visible.
panel.setLayout(new FlowLayout()); d) An exception will occur.
50. Find the missing statement: To refresh the content of a JPanel, call ______.
a) repaint() b) setLayout() c) updateComponent() d) reload()
51. . Which of the following components is used to create a text box where the user can enter a single line of text?
a) JTextArea b) JTextField c) JLabel d) JEditorPane
52. Find the missing statement: To respond to a selection event in a JComboBox, use ______.
a) addSelectionListener() b) addActionListener()
c) addItemListener() d) addComboListener()
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR / 63
2024-2025
Sub Name : Advanced Java Programming (AJP -22517) Course Code : CM-5-I
Name : Date: / /2024
Roll No : Set: I
Practice Test: [ Unit VI -Severlet ]
10. Which method can be used to send a response to the client in a servlet?
a) getRequest() b) sendResponse() c) getResponse() d) HttpServletResponse.getWriter()
11. How can you obtain the value of a request parameter in a servlet?
a) Using the `request.getAttribute()` method b) Using the `request.getParameter()` method
c) Using the `request.getSession()` method d) Using the `request.getAttribute()` method
14. Which HTTP status code indicates that a resource is not found?
a) 200 OK b) 302 Found c) 404 Not Found d) 500 Internal Server Error
20. Which of the following is NOT a valid way to create a servlet in Java?
a) Extending the `HttpServlet` class b) Implementing the `Servlet` interface
c) Using the `new` keyword d) Extending the `GenericServlet` class
25. Which of the following is NOT a valid method of communication between servlets?
a) Using the `ServletContext` b) Using the `HttpServletResponse`
c) Using the `RequestDispatcher` d) Using HTTP sessions
27. Which HTTP method is used to retrieve data from the server in a safe and idempotent way?
a) GET b) POST c) PUT d) DELETE
35. Which of the following is NOT a valid content type for an HTTP response?
a) text/html b) application/json c) image/png d) audio/mp3
41. Which of the following is NOT a valid HTTP status code for a successful response?
a) 200 OK b) 201 Created c) 204 No Content d) 404 Not Found
44. Which of the following is NOT a valid method of managing session tracking in servlets?
a) Using cookies b) Using URL rewriting c) Using session IDs d) Using request attributes
45. Which of the following is NOT a valid content type for an HTTP response?
a) text/html b) application/json c) image/jpeg d) audio/wav
51. Which of the following is NOT a valid HTTP response header in a servlet?
a) Content-Type b) Location c) Session-ID d) Set-Cookie
53. How can you include the content of another resource in a servlet response?
a) By using the `RequestDispatcher.include()` method b) By using the `HttpServletResponse.include()` method
c) By using the `RequestDispatcher.forward()` method d) By using the `HttpServletResponse.forward()` method
54. How can you obtain the value of a servlet's initialization parameter in a servlet?
a) Using the `initParameter()` method of the `ServletConfig` object
b) Using the `getParameter()` method of the `HttpServletRequest` object
c) Using the `getAttribute()` method of the `ServletContext` object
d) Using the `getParameter()` method of the `HttpServletResponse` object
55.How is the dynamic interception of requests and responses to transform the information done.
a)sevlet container b)servlet config c)servlet context d)sevlet filter
58.Which Cookie it is valid for single session only and it is removed each time when the user closes the browser. a)President
Cookie
b)Non-president cookie
c)all of the above
d)None of the above
59.Session is the part of the SessionTracking and it is for maintaining the client state at server side.
a)true b)false c)none d)All
63.Which method is used send the same request and response objects to another servlet in RequestDispatcher().
a)forward b)sendRedirect() c)Both a and a d)None of the above
Sanjivani Rural Education Society’s
SANJIVANI K. B. P. POLYTECHNIC
Department of Computer Technology
KOPARGAON – 423601, DIST: AHMEDNAGAR
2023-2024
/60
Sub : AJP (22517) Pratice Test: [Unit IV - Networking Basics] Date : / /2023
Name : Course Code : CM-5-I
Roll No : Set : II
1. What does the acronym "HTTP" stand for in the context of web communication?
A. Hyperlink Transfer Protocol B. Hypertext Transfer Protocol
C. Hyper Transfer Text Protocol D. High-Speed Text Protocol
2. In Java, which class is commonly used to establish a server socket for network communication?
A. Socket B. ServerSocket C. DatagramSocket D. InetAddress
3. Which Java package provides classes for working with sockets and networking?
A. java.net B. java.io C. java.lang D. java.util
7. In Java, which protocol is used for transferring files over the network?
A. HTTP B. FTP C. TCP D. UDP
8. Which Java class is used to read and write binary data over a network stream?
A. BufferedReader B. BufferedWriter C. ObjectInputStream D.DataInputStream
10. Which Java class allows you to create and manage URL objects?
A. URLBuilder B. URLManager C. URLEncoder D. URLConnection
13. Which protocol is commonly used for sending email in Java applications?
a) FTP b) SMTP c) HTTP d) Telnet
15. Which Java library is commonly used for making HTTP requests?
a) java.net b) javax.servlet c) java.http d) java.httpclient
18. Which Java class is used for handling UDP (User Datagram Protocol) communication?
a) DatagramSocket b) UDPSocket c) DatagramConnection d) UDPConnection
19. Which Java class is used for reading from and writing to streams?
a) Stream b) InputStream c) OutputStream d) StreamReader
21. Which Java method is used to establish a connection to a remote server using TCP/IP?
a) connect() b) open() c) accept() d) bind()
22. Which protocol is used for secure communication over the internet?
a) SSL b) HTTP c) FTP d) Telnet
26. In Java, which protocol is commonly used for sending and receiving email?
a. FTP b. SMTP c. HTTP d. POP3
28. Which Java class is used for reading and writing data to a network socket?
a. ServerSocket b. Socket c. DatagramSocket d. InputStreamReader
32. Which exception is typically thrown when a network operation fails in Java?
a. NetworkException b. IOException c. MalformedURLException d. DataFormatException
33. Which Java class is commonly used to establish a client-server connection for network communication?
a) Socket b) Datagram c) URLConnection d) HttpRequest
35. Which class is used to create servers that listen for either local client or remote client programs?
a. ServerSockets b. httpServer c. httpResponse d. None of the above
48. Which class can be used to create a server socket. This object is used to establish communication with the clients?
A. ServerSocket B. Socket C. Both A & B D. None of the above
49. Which methods are commonly used in ServerSocket class?
A. public OutputStream getOutputStream() B. public Socket accept()
C. public synchronized void close() D. None of the above
52. The URLConnection class can be used to read and write data to the specified resource referred by the URL?
A. True B. False
54. In InetAddress class which method it returns the host name of the IP Address?
A. public String getHostName() B. public String getHostAddress()
C. public static InetAddress getLocalHost() D. None of the above
a. Correct b. Incorrect
a. Yes b. No
a. Correct b. Incorrect
60. Check out whether the following code contains error(s) or not.
import javax.net.*;
public class Net1
{
public static void main(String arg[])throws MaiformedURLException
{
61. Check out whether the following code contains error(s) or not.
import java.io.*;
import java.net.*;
import java.util.Date;
public class URLINFORMATION
{
public static void main(String args[])
{
URL =new URL("http://www.msbte.com");
URLConnection con = url.openConnection();
System.out.println("");
System.out.println(url);
System.out.println("Date:"+new Date(con.getDate()));
System.out.println("Content-Type"+con.getContentType());
System.out.println("Expiers:"+con.getExpiration());
System.out.println("Last-Modified:"+new Date(con.getLastModified()));
int len = con.getContentLength();
System.out.println("Content-Length:"+len);
}
}
a . Correct b. Incorrect
63. Which of the following Java code snippets correctly opens a server socket on port 8080?
64. Which Java code snippet is used to establish a client socket connection to a server at IP address "192.168.1.100" and port 12345?
65. Which of the following Java code snippets is used to set up a UDP socket for sending and receiving datagrams?
67. Which of the following Java code snippets correctly sends an HTTP GET request to a server at "example.com" on port 80?
68. You want to create a Java program to establish a client-server connection. Which code snippet correctly creates a client socket
and connects to a server running on "localhost" at port 8080?
69. You are developing a Java program to establish a server-client connection. Which code snippet correctly creates a server socket
that listens on port 8888 and accepts incoming connections from clients?