Assignment Solution 10
Assignment Solution 10
PROGRAMMING IN JAVA
Assignment 10
TYPE OF QUESTION: MCQ
Number of questions: 10 Total marks: 10 × 1 = 10
QUESTION 1:
JLabel
JButton
JTextField
JPanel
Correct Answer:
JButton
Detailed Solution:
QUESTION 2:
Correct Answer:
Detailed Solution:
A toggle button allows users to switch between two states, such as "on" or "off." It behaves like a
checkbox, but it is represented as a button.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 3:
What is the primary purpose of SQL(Structured Query Language) in Java application ? Commented [NP1]: Already given in W11, requesting to
change the question
To create and amange user interfaces Commented [DM2R1]: Thanks , question changed.
Correct Answer:
Detailed Solution:
SQL is used in Java applications primarily to connect to databases, retrieve data, update records, and
perform other database operations, making it essential for handling data within applications.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 4:
isActive()
isUp()
isRunning()
isConnected()
Correct Answer:
isUp()
Detailed Solution:
In Java, the isUp() method is used to check whether a network interface is up and running. This
method is part of the NetworkInterface class from the java.net package.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 5:
Correct Answer:
Detailed Solution:
In Java, Socket and ServerSocket are the primary components used for establishing client-server
communication. These classes belong to the java.net package and are fundamental to networking in
Java. String, Integer, JFrame, JButton, Scanner, and System are not used for basic networking
functionality.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 6:
https://nptel.ac.in
Correct Answer:
Detailed Solution:
Resource name is nptel.ac.in. The protocol used is https and hence provides a secure connection to the
website. The link is complete in all aspects and hence can open a website (if hosted). The ac.in portion of
the website is top-level domain part and not a path.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 7:
TCP
UDP
ARP
SMTP
Correct Answer:
SMTP
Detailed Solution:
TCP, UDP are transport layer protocols. ARP is a Network - IP layer protocol. SMTP is Application layer
protocol.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 8:
import java.sql.*;
a. Connects to a MySQL database, retrieves data from the "employees" table, and prints it
Correct Answer:
a. Connects to a MySQL database, retrieves data from the "employees" table, and prints it
Detailed Solution:
The code snippet establishes a connection to a MySQL database, executes a SELECT query to retrieve
data from the "employees" table, and prints the results.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 9:
a. URLConnection
b. HttpURL
c. NetURL
d. URL
Correct Answer:
d. URL
Detailed Solution:
The URL class provides methods to work with Uniform Resource Locators.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 10:
Socket
ServerSocket
DatagramSocket
HttpURLConnection
Correct Answer:
b. ServerSocket
Detailed Solution:
ServerSocket is used to listen for incoming connections on a specific port, enabling communication
with clients in server-client applications.