Sanjivani K.B.P. Polytechnic 2023-2024 Practice Test PDF

Document Details

CatchyField5350

Uploaded by CatchyField5350

Sanjivani K.B.P. Polytechnic

2024

Tags

Java networking computer networking protocols internet

Summary

This is a practice test from Sanjivani K.B.P. Polytechnic, 2023-2024, focusing on networking basics. The test covers topics such as web communication protocols (HTTP), Java networking classes, and protocols used for data transfer.

Full Transcript

Sanjivani Rural Education Society’s SANJIVANI K. B. P. POLYTECHNIC Department of Computer Technology KOPARGAON – 423601, DIST: AHMEDNAGAR...

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 4. Which protocol is typically used for sending email in Java applications? A. HTTP B. FTP C. SMTP D. POP3 5. Which Java class is used to represent an IP address? A. IPAdress B. InetAddress C. IPHost D. HostAddress 6. What is the purpose of the "URLConnection" class in Java? A. To represent a URL connection B. To establish a secure SSL connection C. To handle HTTP requests and responses D. To encode and decode URLs 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 9. What is the role of the "SocketTimeoutException" in Java networking? A. It indicates a successful network connection. B. It occurs when a socket is closed gracefully. C. It signals a timeout when waiting for data on a socket. D. It represents an error in the socket's IP address. 10. Which Java class allows you to create and manage URL objects? A. URLBuilder B. URLManager C. URLEncoder D. URLConnection 11. What does HTTP stand for in the context of networking? a) Hyper Transfer Text Protocol b) Hypertext Transfer Protocol c) Hyperlink Text Transfer Protocol d) Hypertext Transmission Protocol 12. Which Java class is used for creating network sockets? a) Socket b) ServerSocket c) DatagramSocket d) InetAddress 13. Which protocol is commonly used for sending email in Java applications? a) FTP b) SMTP c) HTTP d) Telnet 14. In Java, which class is used to represent an IP address? a) IP b) IPAddress c) InetAddress d) InetAddressUtils 15. Which Java library is commonly used for making HTTP requests? a) java.net b) javax.servlet c) java.http d) java.httpclient 16. What does DNS stand for? a) Dynamic Network System b) Domain Name System c) Data Network Service d) Digital Network Security 17. Which port is commonly used for HTTP communication? a) 21 b) 80 c) 443 d) 8080 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 20. What is the primary purpose of a firewall in a network? a) To increase network speed b) To block all incoming and outgoing traffic c) To protect the network from unauthorized access and threats d) To reroute network traffic 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 23. What is the purpose of the InetAddress class in Java? a) To represent IP addresses b) To establish socket connections c) To send emails d) To read from files 24. Which of the following is not a valid IP address format? a) 192.168.1.1 b) 300.200.100.50 c) 10.0.0.1 d) 172.16.0.0 25. Which Java class is used for creating a server socket? a) SocketServer b) ServerSocket c) TCPServer d) NetworkServer 26. In Java, which protocol is commonly used for sending and receiving email? a. FTP b. SMTP c. HTTP d. POP3 27. What is the purpose of the HttpURLConnection class in Java? a. To connect to a database b. To establish a secure connection c. To work with HTTP connections d. To create a UDP socket 28. Which Java class is used for reading and writing data to a network socket? a. ServerSocket b. Socket c. DatagramSocket d. InputStreamReader 29. In Java networking, what is the purpose of the InetAddress.getByName() method? a. To get the IP address of a domain name b. To retrieve the host's hostname c. To set the local host's IP address d. To create a new InetAddress object 30. What is the role of the java.net.URL class in networking? a. To read and write files locally b. To manage database connections c. To represent a Uniform Resource Locator d. To encrypt data during transmission 31.Which Java package is commonly used for socket programming? a. java.sql b. java.io c. java.util d. java.net 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 34. Which of these class is used to encapsulate IP address and DNS? a) DatagramPacket b) URL c) InetAddress d) ContentHandler 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 36. What does IP stand for in networking?* a. Internet Protocol b. Internet Port c. Internal Protocol d. Internet Portability 37. Which class in Java allows you to create a client socket? a. ServerSocket b. Socket c. DatagramSocket d. InetAddress 38. Which socket type is used for UDP communication in Java? a. DatagramSocket b. ServerSocket c. Socket d. MulticastSocket 39. What is the main advantage of TCP over UDP in networking? a. Lower latency b. Connection-oriented c. Suitable for broadcasting d. Simple error handling 40. Which of these class is used to encapsulate IP address and DNS? a) DatagramPacket b) URL c) InetAddress d) ContentHandler 41.The client in socket programming must know which informations? a. IPaddress of Server b. Port number c. Both A & B d. None of the above 42. What does the java.net.InetAddress class represent? a. Socket b. IP Address c. Protocol d. MAC Address 43. Which classes are used for connection-less socket programming? a. DatagramSocket b. DatagramPacket c. Both A & B d.None of the above 44. 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 45. Show some networking terminologies given below? A. IP Address B. Protocol C. MAC Address D. All mentioned above 46. TCP,FTP,Telnet,SMTP,POP etc. are examples of ? A. Socket B. IP Address C. Protocol D. MAC Address 47. Which classes are used for connection-oriented socket programming? A. Socket B. ServerSocket C. Both A & B 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 50. URL is an acronym for? A. Uniform Resource Locator B. Unified Resource Locator C. Uniform Restore Locator D. Unified Restore Locator 52. The URLConnection class can be used to read and write data to the specified resource referred by the URL? A. True B. False 53. The java.net.InetAddress class represents an? A. Socket B. IP Address C. Protocol D. MAC Address 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 55. Which classes are used for connection-less socket programming? A. DatagramSocket B. DatagramPacket C. Both A & B D. None of the above 56. Check whether the following code is correct or not? import javax.net.*; import java.io.*; public class Net1 { public static void main(String args[]) { try { InetAddress ip=InetAddress.getByName("www.javapoint.com"); System.out.println("Host Name: "+ip.getHostName()); System.out.println("Host Address: "+ip.getHostAddress()); } catch(Exception e) { System.out.println(e); } } } a. Correct b. Incorrect 57. Figure out the error(s) in the following code? import javax.net.*; import java.io.*; public class Net1 { public static void main(String args[]) { try { InetAddress ip=InetAddress.getByName("www.javapoint.com"); System.out.println("Host Name: "+ip.getHostNam()); System.out.println("Host Address: "+ip.getHostAddress()); } catch(Exception e) { System.out.println(e); } } } a. In import package b. In Try c. In System.out.println d. Both (a) and (c) 58. In the following code, do we require try-catch compulsorily? import javax.net.*; import java.io.*; public class Net1 { public static void main(String args[]) { try { InetAddress ip=InetAddress.getByName("www.javapoint.com"); System.out.println("Host Name: "+ip.getHostName()); System.out.println("Host Address: "+ip.getHostAddress()); } catch(Exception e) { System.out.println(e); } } } a. Yes b. No 59. Check whether the following code is correct or not? import javax.net.*; public class Net1 { public static void main(String args[])throws Exception { URL u=new URL("https://www.google.com"); System.out.println("Protocol: "+u.getProtocol()); System.out.println("Port: "+u.getPort()); System.out.println("Host: "+u.getHost()); System.out.println("File: "+u.getFile()); System.out.println("Ref: "+u.getRef()); System.out.println("Exit: "+u.getExternalForm()); } } 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 { URL u=new URL("https://www.google.com"); System.out.println("Protocol: "+u.getProtocol()); System.out.println("Port: "+u.getPort()); System.out.println("Host: "+u.getHost()); System.out.println("File: "+u.getFile()); System.out.println("Ref: "+u.getRef()); System.out.println("Exit: "+u.getExternalForm()); } } a. No Errors Present b.Errors Present 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. In URLConnection Line b. In URlCreation Line c. Both (a) and (b) d. None 62. Check whether the following code is correct or not? import java.io.*; import java.net.*; public class InetDemo222 { public static void main(String args[]) { try { InetAddress address = InetAddress.getLocalHost(); System.out.println(address); address = InetAddress.getByName("www.google.com"); System.out.println(address); InetAddress sw[] = InetAddress.getAllByName("www.yahoo.com"); for(int i=0; i

Use Quizgecko on...
Browser
Browser