You are on page 1of 68

1. Which of the following contains both date and time?

a) java.io.date
b) java.sql.date
c) java.util.date
d) java.util.dateTime
View Answer
Answer: d
Explanation: java.util.date contains both date and time. Whereas, java.sql.date contains
only date.
2. Which of the following is advantage of using JDBC connection pool?
a) Slow performance
b) Using more memory
c) Using less memory
d) Better performance
View Answer
Answer: d
Explanation: Since the JDBC connection takes time to establish. Creating connection at
the application start-up and reusing at the time of requirement, helps performance of the
application.
3. Which of the following is advantage of using PreparedStatement in Java?
a) Slow performance
b) Encourages SQL injection
c) Prevents SQL injection
d) More memory usage
View Answer
Answer: c
Explanation: PreparedStatement in Java improves performance and also prevents from
SQL injection.
4. Which one of the following contains date information?
a) java.sql.TimeStamp
b) java.sql.Time
c) java.io.Time
d) java.io.TimeStamp
View Answer
Answer: a
Explanation: java.sql.Time contains only time. Whereas, java.sql.TimeStamp contains
both time and date.
5. What does setAutoCommit(false) do?
a) commits transaction after each query
b) explicitly commits transaction
c) does not commit transaction automatically after each query
d) never commits transaction
View Answer
Answer: c
Explanation: setAutoCommit(false) does not commit transaction automatically after each
query. That saves lot of time of the execution and hence improves performance.
6. Which of the following is used to call stored procedure?
a) Statement
b) PreparedStatement
c) CallableStatment
d) CalledStatement
View Answer
Answer: c
Explanation: CallableStatement is used in JDBC to call stored procedure from Java
program.
7. Which of the following is used to limit the number of rows returned?
a) setMaxRows(int i)
b) setMinRows(int i)
c) getMaxrows(int i)
d) getMinRows(int i)
View Answer
Answer: a
Explanation: setMaxRows(int i) method is used to limit the number of rows that the
database returns from the query.
advertisement

8. Which of the following is method of JDBC batch process?


a) setBatch()
b) deleteBatch()
c) removeBatch()
d) addBatch()
View Answer
Answer: d
Explanation: addBatch() is a method of JDBC batch process. It is faster in processing
than executing one statement at a time.
9. Which of the following is used to rollback a JDBC transaction?
a) rollback()
b) rollforward()
c) deleteTransaction()
d) RemoveTransaction()
View Answer
Answer: a
Explanation: rollback() method is used to rollback the transaction. It will rollback all the
changes made by the transaction.
10. Which of the following is not a JDBC connection isolation levels?
a) TRANSACTION_NONE
b) TRANSACTION_READ_COMMITTED
c) TRANSACTION_REPEATABLE_READ
d) TRANSACTION_NONREPEATABLE_READ
View Answer
Answer: d
Explanation: TRANSACTION_NONREPEATABLE_READ is not a JDBC connection
isolation level.

JDBC MCQ Interview Questions


with Answers set-2
1. A Java program cannot directly communicate with an ODBC driver
because …….

A) ODBC written in C language

B) ODBC written in C# language

C) ODBC written in C++ language

D) ODBC written in Basic language


2.The JDBC-ODBC Bridge driver translates the JDBC API to the ODBC API
and used with …….
A) JDBC drivers

B) ODBC drivers
C) Both A and B

D) None of the above

3. The ……………………….. package contains classes that help in


connecting to a database, sending SQL statements to the database,
and processing the query results.

A) connection.sql
B) db.sql

C) pkg.sql

D) java.sql

4. The ………………………….. method executes a simple query and


returns a single Result Set object.

A) executeUpdate()

B) executeQuery()

C) execute()

D) noexecute()

5. The ……………………. method executes an SQL statement that may


return multiple results.

A) executeUpdate()

B) executeQuery()

C) execute()

D) noexecute()

6. The …………………… object allows you to execute parametrized


queries.

A) ResultSet
B) Parametrized

C) PreparedStatement

D) Condition

7. The ……………… object provides you with methods to access data


from the table.

A) ResultSet
B) Parametrized

C) TableStatement

D) Condition

8. The parameters of the PreparedStatement object are ………………….


when the user clicks on the Query button.

A) initialized

B) started

C) paused

D) stopped

9. The …………………. method sets the query parameters of the


PreparedStatement Object.

A) putString()

B) insertString()

C) setString()

D) setToString()

10. Connection object can be initialized using the ……………………….


method of the Driver Manager class.

A) putConnection()

B) setConnection()

C) Connection()

D) getConnetion()

Answers:
1. A Java program cannot directly communicate with an ODBC driver
because …….
A) ODBC written in C language

2.The JDBC-ODBC Bridge driver translates the JDBC API to the ODBC API
and used with …….

B) ODBC drivers

3. The ……………………….. package contains classes that help in


connecting to a database, sending SQL statements to the database,
and processing the query results.

D) java.sql

4. The ………………………….. method executes a simple query and


returns a single Result Set object.

B) executeQuery()

5. The ……………………. method executes an SQL statement that may


return multiple results.

C) execute()

6. The …………………… object allows you to execute parametrized


queries.

C) PreparedStatement

7. The ……………… object provides you with methods to access data


from the table.

A) ResultSet

8. The parameters of the PreparedStatement object are ………………….


when the user clicks on the Query button.

A) initialized

9. The …………………. method sets the query parameters of the


PreparedStatement Object.

C) setString()
10. Connection object can be initialized using the ……………………….
method of the Driver Manager class.

D) getConnetion()

Section 33.2 Client/Server Computing


33.1 When creating a server on a port that is already in use, __________.

A. java.net.BindException occurs

B. the server is created with no problems

C. the server is blocked until the port is available

D. the server encounters a fatal error and must be terminated

Your answer D is incorrect


The correct answer is A

33.2 When creating a client on a server port that is already in use, __________.

A. the client can connect to the server regardless of whether the port is in use

B. java.net.BindException occurs

C. the client is blocked until the port is available

D. the client encounters a fatal error and must be terminated

Your answer is correct


Explanation: To connect to a client, the server creates a client socket from the ServerSocket. You can
create any number of client sockets on the server side to connect to a client on the Internet.

33.3 The server listens for a connection request from a client using 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);

Your answer A is incorrect


The correct answer is B

33.4 The client requests a connection to a server using 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);

Your answer is correct


33.5 When a client requests connection to a server that has not yet started, __________.

A. java.net.BindException occurs

B. java.net.ConnectionException occurs

C. the client is blocked until the server is started

D. the client encounters a fatal error and must be terminated

Your answer A is incorrect


The correct answer is B

33.7 To create an InputStream on a socket s, you use __________.

A. InputStream in = new InputStream(s);

B. InputStream in = s.getInputStream();

C. InputStream in = s.obtainInputStream();

D. InputStream in = s.getStream();

Your answer A is incorrect


The correct answer is B

Section 33.3 The InetAddress Class


33.8 ______________ models an IP address, which can be used to find the host name and IP address of the
client.

A. The ServerSocket class

B. The Socket class

C. The InetAddress class

D. The Connection interface

Your answer A is incorrect


The correct answer is C

33.9 You can invoke ______________ on a Socket object, say socket, to obtain an InetAddress object.

A. socket.InetAddress();

B. socket.getInetAddress();

C. socket.obtainInetAddress();

D. socket.retrieveInetAddress();
Your answer A is incorrect
The correct answer is B

33.10 The ____________ method in the InetAddress class returns the IP address.

A. getIP()

B. getIPAddress()

C. getHostAddress()

D. getAddress()

Your answer B is incorrect


The correct answer is C

Section 33.4 Serving Multiple Clients


33.11 A ServerSocket can connect to ________ clients.

A. one

B. two

C. ten

D. an unlimited number of

Your answer is correct

Section 33.5 Applet Clients


33.12 You can obtain the server's hostname by invoking _________ on an applet.

A. getCodeBase().host()

B. getCodeBase().getHost()

C. getCodeBase().hostName()

D. getCodeBase().getHostName()

Your answer is correct

Section 33.6 Sending and Receiving Objects


33.13 To obtain an ObjectInputStream from a socket, use ________.

A. socket.getInputStream()

B. socket.getObjectStream()

C. socket.getObjectInputStream()

D. socket.objectInputStream()

E. new ObjectInputStream(socket.getInputStream());
Your answer C is incorrect
The correct answer is E

33.14 To obtain an ObjectOutputStream from a socket, use ________.

A. socket.getOutputStream()

B. socket.getObjectStream()

C. socket.getObjectOutputStream()

D. socket.objectOutputStream()

E. new ObjectOutputStream(socket.getOutputStream())

Your answer C is incorrect


The correct answer is E

a
When creating a client on a server port that is already in use, __________.

A. the client can connect to the server regardless of whether the port is in use.
B. java.net.BindException occurs.
C. the client is blocked until the port is available.
D. the client encounters a fatal error and must be terminated.

a
The client requests a connection to a server using 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);

b
When a client requests connection to a server that has not yet started,
__________.

A. java.net.BindException occurs.
B. java.net.ConnectionException occurs.
C. the client is blocked until the server is started.
D. the client encounters a fatal error and must be terminated.

b
o create an InputStream on a socket s, you use __________.

A. InputStream in = new InputStream(s);


B. InputStream in = s.getInputStream();
C. InputStream in = s.obtainInputStream();
D. InputStream in = s.getStream();

c
______________ models an IP address, which can be used to find the host
name and IP address of the client.

A. The ServerSocket class


B. The Socket class
C. The InetAddress class
D. The Connection interface

c
The ____________ method in the InetAddress class returns the IP address.

A. getIP()
B. getIPAddress()
C. getHostAddress()
D. getAddress()

d
A ServerSocket can connect to ________ clients.

A. one
B. two
C. ten
D. an unlimited number of

b
You can obtain the server's hostname by invoking _________ on an applet.

A. getCodeBase().host()
B. getCodeBase().getHost()
C. getCodeBase().hostName()
D. getCodeBase().getHostName()

e
To obtain an ObjectOutputStream from a socket, use ________.
A. socket.getOutputStream()
B. socket.getObjectStream()
C. socket.getObjectOutputStream()
D. socket.objectOutputStream()
E. new ObjectOutputStream(socket.getOutputStream())
D
You can invoke ______________ on a Socket object, say socket, to obtain an
InetAddress object.
A. socket.obtainInetAddress();
B. socket.InetAddress();
C. socket.retrieveInetAddress();
D. socket.getInetAddress();

D
To connect to a server running on the same machine with the client, which of
the following can be used for the hostname?
A. InetAddress.getLocalHost(),
B. "127.0.0.1"
C. "localhost"
D. All of the above.

A
The server listens for a connection request from a client using the following
statement:
A. Socket s = serverSocket.accept()
B. Socket s = new Socket(ServerName);
C. Socket s = serverSocket.getSocket()
D. Socket s = new Socket(ServerName, port);

B
The server can create a server socket regardless of whether the port is in use
or not.
A. true
B. false

A
The client can connect to the server regardless of whether the port is in use or
not.
A. true
B. false

B
You cannot get instances of InputStream or OutputStream because
InputStream and OutputStream are abstract classes.
A. true
B. false

B
An applet cannot connect to a server program on a Web server where the
applet was loaded.
A. false
B. true

B
You can transmit objects over the socket.
A. false
B. true
B
getInputStream() and getOutputStream() are used to produce InputStream
and OutputStream on the socket.
A. false
B. true

A
Invoking Class.forName method may throw ___________.
A. ClassNotFoundException
B. RuntimeException
C. IOException
D. SQLException

B
In a relational data model, _________ defines the representation of the data.
A. SQL
B. Structure
C. Language
D. Integrity

A
Which of the following statements loads the JDBC-ODBC driver?
A. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
B. Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)
C. Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")
D. Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)

A
To create a statement on a Connection object conn, use
A. Statement statement = conn.createStatement();
B. Statement statement = conn.statement();
C. Statement statement = Connection.createStatement();
D. Statement statement = connection.create();

B
22 A database URL for an access database source test is ________.
A. jdbcodbc:test
B. jdbc:odbc:test
C. test
D. sun.jdbc:odbc:test

A
Database meta data are retrieved through ____________.
A. a Connection object
B. a PreparedStatement object
C. a Statement object
D. a ResultSet Object

A
What is the return value from
stmt.executeUpdate("insert into T values (100, 'Smith')")
A. an int value indicating how many rows are effected from the invocation
B. void
C. a value indicating whether the SQL statement has been executed
successfully
D. an object that contains the status of the execution

C
A database URL for a MySQL database named test on host
panda.armstrong.edu is ________.
A. jdbc:mysql:/panda.armstrong.edu/test
B. jdbc.mysql://panda.armstrong.edu/test
C. jdbc:mysql://panda.armstrong.edu/test
D. jdbc.mysql.//panda.armstrong.edu/test

D
27 In a relational data model, _________ imposes constraints on the data.
A. Language
B. Structure
C. SQL
D. Integrity

B
To execute a SELECT statement "select * from Address" on a Statement
object stmt, use
A. stmt.executeUpdate("select * from Address");
B. stmt.executeQuery("select * from Address");
C. stmt.query("select * from Address");
D. stmt.execute("select * from Address");

A
29 _________ specify the permissible values for an attribute.
A. Domain constraints
B. intra-relational constraints
C. Primary key constraints
D. inter-relational constraints
E. Foreign key constraints

C
31 What information may be obtained from a ResultSetMetaData object?
A. number of rows in the result set
B. JDBC driver name and version
C. number of columns in the result set
D. database URL and product name

C
32 ________ is an attribute or a set of attributes that uniquely identifies the
relation.
A. A primary key
B. A key
C. A superkey
D. A candidate key

C
34 Where is com.mysql.jdbc.Driver located?
A. in the standard Java library bundled with JDK
B. in a JAR file classes12.jar
C. in a JAR file mysqljdbc.jar

B
To connect to a local MySQL database named test, use
A. Connection connection =
DriverManager.getConnection(jdbc:mysql://localhost/test);
B. Connection connection =
DriverManager.getConnection("jdbc:mysql://localhost/test");
C. Connection connection =
DriverManager.connect("jdbc:mysql://localhost/test");
D. Connection connection =
DriverManager.getConnection("mysql:jdbc://localhost/test");

D
Result set meta data are retrieved through ____________.
A. a Connection object
B. a PreparedStatement object
C. a Statement object
D. a ResultSet Object

1. Which of these package contains classes and interfaces for networking?


a) java.io
b) java.util
c) java.net
d) java.network
View Answer
Answer: c
Explanation: None.
2. Which of these is a protocol for breaking and sending packets to an address across a
network?
a) TCP/IP
b) DNS
c) Socket
d) Proxy Server
View Answer
Answer: a
Explanation: TCP/IP – Transfer control protocol/Internet Protocol is used to break data
into small packets an send them to an address across a network.
3. How many ports of TCP/IP are reserved for specific protocols?
a) 10
b) 1024
c) 2048
d) 512
View Answer
Answer: b
Explanation: None.
4. How many bits are in a single IP address?
a) 8
b) 16
c) 32
d) 64
View Answer
Answer: c
Explanation: None.
5. Which of these is a full form of DNS?
a) Data Network Service
b) Data Name Service
c) Domain Network Service
d) Domain Name Service
View Answer
Answer: d
Explanation: None.
6. Which of these class is used to encapsulate IP address and DNS?
a) DatagramPacket
b) URL
c) InetAddress
d) ContentHandler
View Answer
Answer: c
Explanation: InetAddress class encapsulate both IP address and DNS, we can interact
with this class by using name of an IP host.
7. What is the output of this program?

1. import java.net.*;
2. class networking
3. {
4. public static void main(String[] args) throws
UnknownHostException
5. {
6. InetAddress obj1 =
InetAddress.getByName("sanfoundry.com");
7. InetAddress obj2 =
InetAddress.getByName("sanfoundry.com");
8. boolean x = obj1.equals(obj2);
9. System.out.print(x);
10. }
11. }

a) 0
b) 1
c) true
d) false
View Answer
Answer: c
Explanation: None.
Output:
$ javac networking.java
$ java networking
true

8. What is the output of this program?

1. import java.net.*;
2. public class networking
3. {
4. public static void main(String[] args) throws
UnknownHostException
5. {
6. InetAddress obj1 = InetAddress.getByName("cisco.com");
7. InetAddress obj2 =
InetAddress.getByName("sanfoundry.com");
8. boolean x = obj1.equals(obj2);
9. System.out.print(x);
10. }
11. }
a) 0
b) 1
c) true
d) false
View Answer
Answer: d
Explanation: InetAddress obj1 = InetAddress.getByName(“cisco.com”); creates object
obj1 having DNS and IP address of cisco.com, InetAddress obj2 =
InetAddress.getByName(“sanfoundry.com”); creates obj2 having DNS and IP address of
sanfoundry.com, since both these address point to two different locations false is
returned by obj1.equals(obj2);.
Output:
advertisement
$ javac networking.java
$ java networking
false

9. What is the output of this program?

1. import java.io.*;
2. import java.net.*;
3. public class URLDemo
4. {
5. public static void main(String[] args)
6. {
7. try
8. {
9. URL url=new URL("https://www.sanfoundry.com/java-mcq");
10. System.out.println("Protocol: "+url.getProtocol());
11. System.out.println("Host Name: "+url.getHost());
12. System.out.println("Port Number: "+url.getPort());
13. } catch(Exception e){System.out.println(e);}
14. }
15. }

a) Protocol: http
b) Host Name: www.sanfoundry.com
c) Port Number: -1
d) all of the mentioned
View Answer
Answer: d
Explanation: getProtocol() give protocol which is http
getUrl() give name domain name
getPort() Since we have not explicitly set the port, default value that is -1 is printed.
10. What is the output of this program?

1. import java.net.*;
2. class networking
3. {
4. public static void main(String[] args) throws
UnknownHostException
5. {
6. InetAddress obj1 = InetAddress.getByName("cisco.com");
7. System.out.print(obj1.getHostName());
8. }
9. }

a) cisco
b) cisco.com
c) www.cisco.com
d) none of the mentioned
View Answer
Answer: b

1. Which methods are commonly used in Server Socket class?


a) Public Output Stream get Output Stream ()
b) Public Socket accept ()
c) Public synchronized void close ()
d) None of the mentioned
View Answer
Answer: b
Explanation: Public Socket accept () used in Server Socket class.
2. Which constructor of Datagram Socket class is used to create a datagram socket and
binds it with the given Port Number?
a) Datagram Socket(int port)
b) Datagram Socket(int port, Int Address address)
c) Datagram Socket()
d) None of the mentioned
View Answer
Answer: b
Explanation: Datagram Socket (int port, Int Address address) is use data create a
datagram socket.
3. The client in socket programming must know which information?
a) IP address of Server
b) Port number
c) Both IP address of Server & Port number
d) None of the mentioned
View Answer
Answer: c
Explanation: The client in socket programming must know IP address of Server.
4. The URL Connection class can be used to read and write data to the specified
resource referred by the URL
a) True
b) False
View Answer
Answer: a
Explanation: The URL Connection class can be used to read and write data to the
specified resource referred by the URL.
5. Datagram is basically an information but there is no guarantee of its content, arrival or
arrival time.
a) True
b) False
View Answer
Answer: a
Explanation: Datagram is basically an information but there is no guarantee of its content,
arrival or arrival time.
6. TCP, FTP, Telnet, SMTP, POP etc. are examples of?
a) Socket
b) IP Address
c) Protocol
d) MAC Address
View Answer
Answer: c
Explanation: TCP, FTP, Telnet, SMTP, POP etc. are examples of Protocol.
7. What does the java.net.InetAddress class represent?
a) Socket
b) IP Address
c) Protocol
d) MAC Address
View Answer
Answer: b
Explanation: The java.net.InetAddress class represent IP Address.
8. The flush () method of Print Stream class flushes any un cleared buffers in memory
a) True
b) False
View Answer
Answer: a
Explanation: The flush () method of Print Stream class flushes any un cleared buffers in
memory.
9. Which classes are used for connection-less socket programming?
a) Datagram Socket
b) Datagram Packet
c) Both Datagram Socket & Datagram Packet
d) None of the mentioned
View Answer
Answer: c
Explanation: Datagram Socket, Datagram Packet are used for connection-less socket
programming.
10. In Int Address class which method returns the host name of the IP Address?
a) Public String get Hostname()
b) Public String getHostAddress()
c) Public static IntAddress get Localhost()
d) None of the mentioned
View Answer
Answer: a
Explanation: In Int Address class public String get Hostname() method returns the host
name of the IP Address.

1. Which one of the following is correct for directive in JSP?


a) <%@directive%>
b) <%!directive%>
c) <%directive%>
d) <%=directive%>
View Answer
Answer: a
Explanation: Directive is declared as <%@directive%>.
2. Which of the following action variable is used to include a file in JSP?
a) jsp:setProperty
b) jsp:getProperty
c) jsp:include
d) jsp:plugin
View Answer
Answer: c
Explanation: jsp:include action variable is used to include a file in JSP.
3. Which attribute uniquely identification element?
a) ID
b) Class
c) Name
d) Scope
View Answer
Answer: a
Explanation: ID attribute is used to uniquely identify action element.
4. “out” is implicit object of which class?
a) javax.servlet.jsp.PrintWriter
b) javax.servlet.jsp.SessionWriter
c) javax.servlet.jsp.SessionPrinter
d) javax.servlet.jsp.JspWriter
View Answer
Answer: d
Explanation: JspWriter object is referenced by the implicit variable out which is initialized
automatically using methods in the PageContext object.
5. Which object stores references to the request and response objects?
a) sessionContext
b) pageContext
c) HttpSession
d) sessionAttribute
View Answer
Answer: b
Explanation: pageContext object contains information about directives issued to JSP
page.
6. What temporarily redirects response to the browser?
a) <jsp:forward>
b) <%@directive%>
c) response.sendRedirect(URL)
d) response.setRedirect(URL)
View Answer
Answer: c
Explanation: response.sendRedirect(URL) directs response to the browser and creates a
new request.
7. Which tag is used to set a value of a JavaBean?
a) <c:set>
b) <c:param>
c) <c:choose>
d) <c:forward>
View Answer
Answer: a
Explanation: <c:set> is used to set a value of a java.util.Map object.
advertisement

8. Can <!–comment–> and <%–comment–%> be used alternatively in JSP?


a) True
b) False
View Answer
Answer: b
Explanation: <!–comment–> is an HTML comment. <%–comment–%> is JSP comment.
9. Java code is embedded under which tag in JSP?
a) Declaration
b) Scriptlet
c) Expression
d) Comment
View Answer
Answer: b
Explanation: Scriptlet is used to embed java code in JSP.
10. Which of the following is not a directive in JSP?
a) page directive
b) include directive
c) taglib directive
d) command directive
View Answer
Answer: d
Explanation: command directive is not a directive in JSP.

1) Show some networking terminologies given below?


A) IP Address
B) Protocol
C) MAC Address
D) All mentioned above
d

2) TCP,FTP,Telnet,SMTP,POP etc. are examples of ?


A) Socket
B) IP Address
C) Protocol
D) MAC Address
c

3) Which classes are used for connection-oriented socket


programming?
A) Socket
B) ServerSocket
C) Both A & B
D) None of the above
c

4) 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

a
5) 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
b

6) URL is an acronym for?


A) Uniform Resource Locator
B) Unified Resource Locator
C) Uniform Restore Locator
D) Unified Restore Locator
a

7) The URLConnection class can be used to read and


write data to the specified resource referred by the URL?
A) True
B) False

a
8) The java.net.InetAddress class represents an?
A) Socket
B) IP Address
C) Protocol
D) MAC Address
b

9) 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

10) Which classes are used for connection-less socket


programming?
A) DatagramSocket
B) DatagramPacket
C) Both A & B
D) None of the above
c

.specify the permissible values for an attribute _________ (1

A. Domain constraints
B. Primary key constraints
C. Foreign key constraints
D. intra-relational constraints
E. inter-relational constraints
ANS: A

?Where is com.mysql.jdbc.Driver located (2

A. in the standard Java library bundled with JDK


B. in a JAR file mysqljdbc.jar downloadable from the book's Companion Website
C. in a JAR file classes12.jar downloadable from the book's Companion Website
D. in a JAR file ojdbc14.jar downloadable from the book's Companion Website
ANS:B

.___________ Invoking Class.forName method may throw(3

A. RuntimeException
B. ClassNotFoundException
C. IOException
D. SQLException
ANS: B

?Which of the following statements are true (4

.A. You may load multiple JDBC drivers in a program


.B. You may create multiple connections to a database
.C. You can send queries and update statements through a Statement object
D. All of the above
ANS: D

The statement ___________ removes the records from the table, but keeps in definition of (5
.the table in the database

;A. destory table Course


;B. drop table Course
;C. delete * from Course
;D. delete Course

ANS: D

?Which of the following statements loads the JDBC-ODBC driver (6

A. Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)
B. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
C. Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)
D. Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")
ANS:B

.___________ Invoking Class.forName method may throw (7

A. RuntimeException
B. ClassNotFoundException
C. IOException
D. SQLException
ANS:B

To create a statement on a Connection object conn, use (8

;()A. Statement statement = conn.statement


;()B. Statement statement = Connection.createStatement
;()C. Statement statement = conn.createStatement
;()D. Statement statement = connection.create
ANS:C

?Which of the following are interfaces(9

A. Connection
B. Statement
C. ResultSet
D. All of the above
ANS:D

What is the return value from(10


stmt.executeUpdate("insert into T values (100, 'Smith')")

A. void
B. an int value indicating how many rows are effected from the invocation
C. a value indicating whether the SQL statement has been executed successfully
D. an object that contains the status of the execution

ANS:B

._____________ You can run JSP from(1

.A. any Web server


.B. any JVM
.C. any Web server that supports Java servlet and JSP
.D. any Web browser
ANS C

?Which of the following statements are true (2


.A. JSP is translated into Java servlet by a Web server when a JSP is called
.B. JSP is translated into HTML by a Web server when a JSP is called
.C. JSP is translated into XML by a Web server when a JSP is called
D. All of the above

ANS: A

.is a JSP scriptlet _______________ (3

<% A. <%= i
<% B. <%= Math.pow(2, 3)
C. <%! private long computeFactorial(int n) { if (n == 0)return 1;else return n *
<% computeFactorial(n - 1); }
<% } D. <% for (int i = 0; i <= 10; i++)
<%-- E. <!-- HTML Comment

ANS: D

.is a JSP comment _______________ (4

<% A. <%= i
<%-- B. <%-- i
C. <%! private long computeFactorial(int n) { if (n == 0) return 1; else return n *
<% computeFactorial(n - 1); }
<% } D. <% for (int i = 0; i <= 10; i++)
<-- E. <!-- HTML Comment

ANS: B

?Which of the following is a JSP implicit object (5

A. request
B. response
C. out
D. session
E. All of the above
ANS: E

.is a JSP expression _______________(6

<% A. <%= i
<% B. <%= Math.pow(2, 3)
<% ()C. <%= new Date().toString
<% } D. <% for (int i = 0; i <= 10; i++)
E. A,B,and C
ANS: E

.is a JSP declaration _______________ (7

<% A. <%= i
<% B. <%= Math.pow(2, 3)
C. <%! private long computeFactorial(int n) { if (n == 0) return 1; else return n *
<% computeFactorial(n - 1); }
<% } D. <% for (int i = 0; i <= 10; i++)
<-- E. <!-- HTML Comment

ANS:C

The ________ directive lets you provide information for the page, such as importing (8
classes and setting up content type. The page directive can appear anywhere in

.the JSP file

A. page
B. include
C. tablib
D. import
ANS: A

.____________________ A class is a JavaBeans component if(9


A. it is a public class
B. it has a public constructor with no arguments
.C. it is serializable
D. All of the above

ANS: D

._________ The JSP explicit object out is actually (10

()A. response.getOutputStream
()B. response.getWriter
()C. request.getOutputStream
()D. request.getWriter
E. application

ANS : B

34.1 In a relational data model, _________ defines the representation of the data.

A. Structure
B. Integrity

C. Language

D. SQL

Your answer is correct


34.2 In a relational data model, _________ imposes constraints on the data.

A. Structure

B. Integrity

C. Language

D. SQL

Your answer is correct


34.3 In a relational data model, ________ provides the means for accessing and manipulating data.

A. Structure

B. Integrity

C. Language

D. SQL

Your answer A is incorrect


Click here to show the correct answer

34.4 _________ specify the permissible values for an attribute.

A. Domain constraints

B. Primary key constraints

C. Foreign key constraints

D. intra-relational constraints

E. inter-relational constraints

Your answer B is incorrect


Click here to show the correct answer

34.6 ________ is an attribute or a set of attributes that uniquely identifies the relation.

A. A superkey

B. A key

C. A candidate key

D. A primary key
Your answer is correct
34.8 To retrieve all courses with more than 3 credit hours, you write

select * from Course


where numOfCredits > 3;

Is this statement correct?

A. Yes

B. No

Your answer is correct

Section 34.4 JDBC


34.9 Which of the following statements loads the JDBC-ODBC driver?

A. Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)

B. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

C. Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)

D. Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")

Your answer is correct


34.10 Where is com.mysql.jdbc.Driver located?

A. in the standard Java library bundled with JDK

B. in a JAR file mysqljdbc.jar downloadable from the book's Companion Website

C. in a JAR file classes12.jar downloadable from the book's Companion Website

D. in a JAR file ojdbc14.jar downloadable from the book's Companion Website

Your answer A is incorrect


Click here to show the correct answer

34.11 Invoking Class.forName method may throw ___________.

A. RuntimeException

B. ClassNotFoundException

C. IOException

D. SQLException

Your answer C is incorrect


Click here to show the correct answer
34.12 A database URL for an access database source test is ________.

A. test

B. jdbcodbc:test

C. jdbc:odbc:test

D. sun.jdbc:odbc:test

Your answer B is incorrect


Click here to show the correct answer

34.13 A database URL for a MySQL database named test on host panda.armstrong.edu is ________.

A. jdbc.mysql.//panda.armstrong.edu/test

B. jdbc:mysql:/panda.armstrong.edu/test

C. jdbc:mysql://panda.armstrong.edu/test

D. jdbc.mysql://panda.armstrong.edu/test

Your answer A is incorrect


Click here to show the correct answer

34.14 To connect to a local MySQL database named test, use

A. Connection connection = DriverManager.getConnection(jdbc:mysql://localhost/test);

B. Connection connection = DriverManager.connect("jdbc:mysql://localhost/test");

C. Connection connection = DriverManager.getConnection("mysql:jdbc://localhost/test");

D. Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/test");

Your answer B is incorrect


Click here to show the correct answer

34.15 To create a statement on a Connection object conn, use

A. Statement statement = conn.statement();

B. Statement statement = Connection.createStatement();

C. Statement statement = conn.createStatement();

D. Statement statement = connection.create();

Your answer D is incorrect


Click here to show the correct answer

34.16 To execute a SELECT statement "select * from Address" on a Statement object stmt, use
A. stmt.execute("select * from Address");

B. stmt.executeQuery("select * from Address");

C. stmt.executeUpdate("select * from Address");

D. stmt.query("select * from Address");

Your answer A is incorrect


Click here to show the correct answer

34.21 What is the return value from

stmt.executeUpdate("insert into T values (100, 'Smith')")

A. void

B. an int value indicating how many rows are effected from the invocation

C. a value indicating whether the SQL statement has been executed successfully

D. an object that contains the status of the execution

Your answer is correct


34.23 Suppose a prepared statement is created as follows:

Statement preparedStatement = connection.prepareStatement


("insert into Student (firstName, mi, lastName) " +
"values (?, ?, ?)");

To set a value John to the first parameter, use

A. preparedStatement.setString(0, "John");

B. preparedStatement.setString(1, "John");

C. preparedStatement.setString(0, 'John');

D. preparedStatement.setString(1, 'John');

Your answer is correct


34.24 If a prepared statement preparedStatement is a SQL SELECT statement, you execute the statement
using _________.

A. preparedStatement.execute();

B. preparedStatement.executeUpdate();

C. preparedStatement.executeQuery();

D. preparedStatement.query();

Your answer B is incorrect


Click here to show the correct answer
34.26 Suppose a callable statement is created as follows:

CallableStatement callableStatement = connection.prepareCall(


"{call sampleProcedure(?, ?, ?)}");

Assume that the first parameter is an IN parameter with value John. To set t
his parameter value, use

A. callableStatement.setString(0, "John");

B. callableStatement.setString(1, "John");

C. callableStatement.setString(0, 'John');

D. callableStatement.setString(1, 'John');

Your answer C is incorrect


Click here to show the correct answer

34.27 Suppose a callable statement is created as follows:

CallableStatement callableStatement = connection.prepareCall(


"{call sampleProcedure(?, ?, ?)}");

Assume that the second parameter is an OUT parameter with value John. To reg
ister this parameter, use

A. callableStatement.registerOutParameter(0, java.sql.Types.STRING);

B. callableStatement.registerOutParameter(1, java.sql.Types.STRING);

C. callableStatement.registerOutParameter(2, java.sql.Types.STRING);

Your answer A is incorrect


Click here to show the correct answer

Section 34.7 Retrieving Metadata


34.28 Database meta data are retrieved through ____________.

A. a Connection object

B. a Statement object

C. a ResultSet Object

D. a PreparedStatement object

Your answer C is incorrect


Click here to show the correct answer and an explanation
34.31 What information may be obtained from a ResultSetMetaData object?

A. database URL and product name

B. JDBC driver name and version

C. number of columns in the result set


D. number of rows in the result set

Your answer is correct

. How does applet and servlet communicate?


a) HTTP
b) HTTPS
c) FTP
d) HTTP Tunneling
View Answer
Answer: d
Explanation: Applet and Servlet communicate through HTTP Tunneling.
2. In CGI, process starts with each request and will initiate OS level process.
a) True
b) False
View Answer
Answer: a
Explanation: A new process is started with each client request and that corresponds to
initiate a heavy OS level process for each client request.
3. Which class provides system independent server side implementation?
a) Socket
b) ServerSocket
c) Server
d) ServerReader
View Answer
Answer: b
Explanation: ServerSocket is a java.net class which provides system independent
implementation of server side socket connection.
4. What happens if ServerSocket is not able to listen on the specified port?
a) The system exits gracefully with appropriate message
b) The system will wait till port is free
c) IOException is thrown when opening the socket
d) PortOccupiedException is thrown
View Answer
Answer: c
Explanation: public ServerSocket() creates an unbound server socket.It throws
IOException if specified port is busy when opening the socket.
5. What does bind() method of ServerSocket offer?
a) binds the serversocket to a specific address (IP Address and port)
b) binds the server and client browser
c) binds the server socket to the JVM
d) binds the port to the JVM
View Answer
Answer: a
Explanation: bind() binds the server socket to a specific address (IP Address and port). If
address is null, the system will pick an ephemeral port and valid local address to bind
socket.
6. Which of the below are common network protocols?
a) TCP
b) UDP
c) TCP and UDP
d) CNP
View Answer
Answer: c
Explanation: Transmission Control Protocol(TCP) and User Datagram Protocol(UDP) are
the two common network protocol. TCP/IP allows reliable communication between two
applications. UDP is connection less protocol.
7. Which class represents an Internet Protocol address?
a) InetAddress
b) Address
c) IP Address
d) TCP Address
View Answer
Answer: a
Explanation: InetAddress represents an Internet Protocol address. It provides static
methods like getByAddress(), getByName() and other instance methods like
getHostName(), getHostAddress(), getLocalHost().
advertisement

8. What does local IP address start with?


a) 10.X.X.X
b) 172.X.X.X
c) 192.168.X.X
d) 10.X.X.X, 172.X.X.X, or 192.168.X.X
View Answer
Answer: d
Explanation: Local IP addresses look like 10.X.X.X, 172.X.X.X, or 192.168.X.X.
9. What happens if IP Address of host cannot be determined?
a) The system exit with no message
b) UnknownHostException is thrown
c) IOException is thrown
d) Temporary IP Address is assigned
View Answer
Answer: b
Explanation: UnknownHostException is thrown when IP Address of host cannot be
determined. It is an extension of IOException.
10. What is the java method for ping?
a) hostReachable()
b) ping()
c) isReachable()
d) portBusy()
View Answer
Answer: c

Application layer mcq

Simple Mail Transfer Protocol (SMTP)

transfers mail

message must be formatted properly

SMTP processes must be running on both the client and server

message header must have a properly formatted recipient email address and a sender uses
port 25 Post Office Protocol (POP)

enables a workstation to retrieve mail from a mail server

mail is downloaded from the server to the client and then deleted on the server uses port
110

POP does not store messages

POP3 is desirable for an ISP, because it alleviates their responsibility for managing large
amounts of storage for their email servers

Dynamic Host Configuration Protocol

DHCP allows a host to obtain an IP address dynamically.

DHCP server is contacted and address requested - chooses address from a configured range
of addresses called a pool and “leases” it to the host for a set period. DHCP used for general
purpose hosts such as end user devices, and static addressing is used for network devices
such as gateways, switches, servers and printers.

Server Message Block

Clients establish a long term connection to servers.

After the connection is established, the user can access the resources on the server as if the
resource is local to the client host.
Domain Name System (DNS): TCP/UDP Port 53

Hypertext Transfer Protocol (HTTP) : TCP Port 80 Simple Mail Transfer Protocol (SMTP) : TCP
Port 25

Post Office Protocol (POP) : UDP Port 110

Telnet : TCP Port 23

Dynamics Host Configuration Protocol (DHCP) : UDP Port 67

File Transfer Protocol (FTP) : TCP Ports 20 and 21

P2P Services and Gnutella Protocol

Gnutella is a P2P file sharing application. Since this is a P2P application, there is no client
and server software. All of them are called peers. With Gnutella, people can make files on
their hard disks available for others to download.

Telnet Services and Protocol

Telnet allows users to remotely access another device (host, router, switch).

DNS Services and Protocol

In the Internet, all end devices have an IP address to enable it to send and receive data over
the network.

Since it is easier to remember names instead of numbers, an end device is also normally
given a domain name.

Domain Name System (DNS) is a service used to convert domain name to IP address.

MCQ

1. The ____________ translates internet domain and host names to IP address.


a) domain name system
b) routing information protocol
c) network time protocol
d) internet relay chat
View Answer
Answer: a
Explanation: None.
2. Which one of the following allows a user at one site to establish a connection to another
site and then pass keystrokes from local host to remote host?
a) HTTP
b) FTP
c) Telnet
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
3. Application layer protocol defines
a) types of messages exchanged
b) message format, syntax and semantics
c) rules for when and how processes send and respond to messages
d) all of the mentioned
View Answer
Answer: d
Explanation: None.
4. Which one of the following protocol delivers/stores mail to reciever server?
a) simple mail transfer protocol
b) post office protocol
c) internet mail access protocol
d) hypertext transfer protocol
View Answer
Answer: a
Explanation: None.
5. The ASCII encoding of binary data is called
a) base 64 encoding
b) base 32 encoding
c) base 16 encoding
d) base 8 encoding
View Answer
6. Which one of the following is an internet standard protocol for managing devices on IP
network?
a) dynamic host configuration protocol
b) simple newtwork management protocol
c) internet message access protocol
d) media gateway protocol
View Answer
Answer: b
Explanation: None.
7. Which one of the following is not an application layer protocol?
a) media gateway protocol
b) dynamic host configuration protocol
c) resource reservation protocol
d) session initiation protocol
View Answer
Answer: c
Explanation: None.
8. Which protocol is a signalling communication protocol used for controlling multimedia
communication sessions?
a) session initiation protocol
b) session modelling protocol
c) session maintenance protocol
d) none of the mentioned
View Answer
9. Which one of the following is not correct?
a) application layer protocols are used by both source and destination devices during a
communication session
b) application layer protocols implemented on the source and destination host must match
c) both (a) and (b)
d) none of the mentioned
View Answer
10. When displaying a web page, the application layer uses the
a) HTTP protocol
b) FTP protocol
c) SMTP protocol
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
1. The number of objects in a Web page which consists of 4 jpeg images and HTML text is
________
a) 4
b) 1
c) 5
d) None of the mentioned
View Answer
Answer: c
Explanation: 4 jpeg images + 1 base HTML file.
2. The default connection type used by HTTP is _________
a) Persistent
b) Non-persistent
c) Either of the mentioned
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
3. The time taken by a packet to travel from client to server and then back to the client is
called __________
a) STT
b) RTT
c) PTT
d) None of the mentioned
View Answer
Answer: b
Explanation: RTT stands for round-trip time.
4. The HTTP request message is sent in _________ part of three-way handshake.
a) First
b) Second
c) Third
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
5. In the process of fetching a web page from a server the HTTP request/response takes
__________ RTTs.
a) 2
b) 1
c) 4
d) 3
View Answer
Answer: b
Explanation: None.
6. The first line of HTTP request message is called _____________
a) Request line
b) Header line
c) Status line
d) Entity line
View Answer
Answer: a
Explanation: The line followed by request line are called header lines and status line is the
initial part of response message.
7. The values GET, POST, HEAD etc are specified in ____________ of HTTP message
a) Request line
b) Header line
c) Status line
d) Entity body
View Answer
Answer: a
Explanation: It is specified in the method field of request line in the HTTP request message.
8. The __________ method when used in the method field, leaves entity body empty.
a) POST
b) GET
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
9. The HTTP response message leaves out the requested object when ____________ method
is used
a) GET
b) POST
c) HEAD
d) PUT
View Answer
Answer: c
Explanation: None.
10. Find the oddly matched HTTP status codes
a) 200 OK
b) 400 Bad Request
c) 301 Moved permanently
d) 304 Not Found
View Answer
Answer: d
Explanation: 404 Not Found.
11. Which of the following is not correct ?
a) Web cache doesnt has its own disk space
b) Web cache can act both like server and client
c) Web cache might reduce the response time
d) Web cache contains copies of recently requested objects
View Answer
Answer: a
Explanation: None.
12. The conditional GET mechanism
a) Imposes conditions on the objects to be requested
b) Limits the number of response from a server
c) Helps to keep a cache upto date
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
13. Which of the following is present in both an HTTP request line and a status line?
a) HTTP version number
b) URL
c) Method
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
1. Multiple object can be sent over a TCP connection between client and server in
a) persistent HTTP
b) nonpersistent HTTP
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
2. HTTP is ________ protocol.
a) application layer
b) transport layer
c) network layer
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
3. In the network HTTP resources are located by
a) uniform resource identifier
b) unique resource locator
c) unique resource identifier
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
4. HTTP client requests by establishing a __________ connection to a particular port on
the server.
a) user datagram protocol
b) transmission control protocol
c) broader gateway protocol
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
5. In HTTP pipelining
a) multiple HTTP requests are sent on a single TCP connection without waiting for the
corresponding responses
b) multiple HTTP requests can not be sent on a single TCP connection
c) multiple HTTP requests are sent in a queue on a single TCP connection
d) none of the mentioned
View Answer

6. FTP server listens for connection on port number


a) 20
b) 21
c) 22
d) 23
View Answer
Answer: b
Explanation: None.
7. In FTP protocol, client contacts server using ____ as the transport protocol.
a) transmission control protocol
b) user datagram protocol
c) datagram congestion control protocol
d) stream control transmission protocol
View Answer
Answer: a
Explanation: None.
8. In which mode FTP, the client initiates both the control and data connections.
a) active mode
b) passive mode
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
9. The file transfer protocol is built on
a) data centric architecture
b) service oriented architecture
c) client server architecture
d) none of the mentioned
View Answer
Answer: c
Explanation: None.
10. In file transfer protocol, data transfer can be done in
a) stream mode
b) block mode
c) compressed mode
d) all of the mentioned
View Answer
Answer: d
Explanation: None.

36 Multiple object can be sent over a TCP connection between client and server in
.

a. persistent HTTP

b. nonpersistent HTTP

c. both (a) and (b)

d. none of the mentioned


Answer: (a).persistent HTTP

37 HTTP is ________ protocol.


.

a. application layer

b. transport layer

c. network layer

d. none of the mentioned

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).application layer

39 HTTP client requests by establishing a __________ connection to a particular port on


.
a. user datagram protocol

b. transmission control protocol

c. broader gateway protocol

d. none of the mentioned

View Answer Report Discuss Too Difficult! Search Google

Answer: (b).transmission control protocol

1. In one of the pairs of protocols given below, both


protocols can use multiple TCP connections betw
the same client and the server. Which one is that

a. HTTP, FTP

b. HTTP, TELNET

c. FTP, SMTP

d. HTTP, SMTP

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).HTTP, FTP

2. Which of the following is/are example(s) of stateful application layer protocols?

(i) HTTP

(ii) FTP

(iii) TCP

(iv) POP3

a. (i) and (ii) only

b. (ii) and (iii) only

c. (ii) and (iv) only

d. (iv) only
View Answer Report Discuss Too Difficult! Search Google

Answer: (c).(ii) and (iv) only

3. Which of the following is the Application layer protocol in Internet Protocol Suite?

a. SSH

b. XMPP

c. IMAP

d. All of the above

View Answer Report Discuss Too Difficult! Search Google

4. The Application layer in TCP/IP contains the ___________ protocols.

a. Routing

b. Routed

c. Communication

d. Process-to-process

View Answer Report Discuss Too Difficult! Search Google

Answer: (c).Communication

5. Which of the following is the Application layer protocol in OSI model?

1.DHCP

2.FTP

3.RSVP
4.NNTP

a. Only 1

b. Only 2

c. Only 3

d. 1, 2 and 4

View Answer Report Discuss Too Difficult! Search Google

Answer: (d).1, 2 and 4

6. Identify the correct order in which the following actions take place in an interactio
web browser and a web server.

1. The web browser requests a webpage using HTTP.

2. The web browser establishes a TCP connection with the web server.

3. The web server sends the requested webpage using HTTP.

4. The web browser resolves the domain name using DNS.

a. 4,2,1,3

b. 1,2,3,4

c. 4,1,2,3

2,4,1,3
d.

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).4,2,1,3

7. What does HTTPS stands for?

a. Hyper Text Transmission Protocols


b. Hyper Text Tile Protocols

c. Hyper Text Transfer Protocol Secure

d. None

View Answer Report Discuss Too Difficult! Search Google

Answer: (c).Hyper Text Transfer Protocol Secure

11. Application layer protocol defines

a. types of messages exchanged

b. message format, syntax and semantics

c. rules for when and how processes send and respond to messages

d. all of the mentioned

View Answer Report Discuss Too Difficult! Search Google

Answer: (d).all of the mentioned

12. Which one of the following protocol delivers/stores mail to receiver server?

a. simple mail transfer protocol

b. post office protocol

c. internet mail access protocol

d. hypertext transfer protocol

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).simple mail transfer protocol

13. The ASCII encoding of binary data is called

a. base 64 encoding

b. base 32 encoding
c. base 16 encoding

d. base 8 encoding

View Answer Report Discuss Too Difficult! Search Google

14. Which one of the following is not an application layer protocol?

a. media gateway protocol

b. dynamic host configuration protocol

c. resource reservation protocol

d. session initiation protocol

View Answer Report Discuss Too Difficult! Search Google

Answer: (c).resource reservation protocol

15. Which protocol is a signalling communication protocol used for controlling multime
communication sessions?

a. session initiation protocol

b. session modelling protocol

c. session maintenance protocol

d. none of the mentioned

View Answer Report Discuss Too Difficult! Search Google

16. Which one of the following is not correct?

a. application layer protocols are used by both source and destination devices during a communication session

b. application layer protocols implemented on the source and destination host must match

c. both (a) and (b)


d. none of the mentioned

View Answer Report Discuss Too Difficult! Search Google

Answer: (c).both (a) and (b)

17. When displaying a web page, the application layer uses the

a. HTTP protocol

b. FTP protocol

c. SMTP protocol

d. none of the mentioned

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).HTTP protocol

18. This is not a application layer protocol

a. HTTP

b. SMTP

c. FTP

d. TCP

View Answer Report Discuss Too Difficult! Search Google

Answer: (d).TCP

19. The chunk of information at the application layer is called

a. Packet

b. Message

c. Segment
d. Frame

View Answer Report Discuss Too Difficult! Search Google

Answer: (b).Message

20. Electronic mail uses this Application layer protocol

a. SMTP

b. HTTP

c. FTP

d. SIP

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).SMTP

65. Simple mail transfer protocol (SMTP) utilizes ____ as the transport layer protocol fo
mail transfer.

a. TCP

b. UDP

c. DCCP

d. SCTP

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).TCP

66. SMTP connections secured by SSL are known as

a. SMTPS

b. SSMTP

c. SNMP

d. none of the above


View Answer Report Discuss Too Difficult! Search Google

Answer: (a).SMTPS

67. SMTP uses the TCP port

a. 22

b. 23

c. 24

d. 25

View Answer Report Discuss Too Difficult! Search Google

Answer: (d).25

68. Which one of the following protocol is used to receive mail messages?

a. SMTP

b. post office protocol

c. internet message access protocol

d. all of the above

View Answer Report Discuss Too Difficult! Search Google

Answer: (d).all of the above

69. What is on-demand mail relay (ODMR)?

a. protocol for SMTP security

b. an SMTP extension

c. protocol for web pages

d. none of the above


View Answer Report Discuss Too Difficult! Search Google

Answer: (b).an SMTP extension

70. An email client needs to know the ____ of its initial SMTP server.

a. IP address

b. MAC address

c. url

d. none of the above

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).IP address

57 FTP uses _____ parallel TCP connections to transfer a file.


.

a. 1

b. 2

c. 3

d. 4

View Answer Report Discuss Too Difficult! Search Google

Answer: (b).2

41. FTP server listens for connection on port number

a. 20

b. 21

c. 22

d. 23

View Answer Report Discuss Too Difficult! Search Google

Answer: (b).21
42. In FTP, client contacts server using ____ as the transport protocol.

a. transmission control protocol

b. user datagram protocol

c. datagram congestion control protocol

d. stream control transmission protocol

View Answer Report Discuss Too Difficult! Search Google

Answer: (a).transmission control protocol

46. What is the port number for HTTP?

a. 25

b. 80

c. 21

d. 65

47 The ______ method when used in the method field, leaves entity body empty.
.

a. POST

b. GET

c. Both of the above

d. None of the above

View Answer Report Discuss Too Difficult! Search Google

Answer: (b).GET

1. Transport layer aggregates data from different applications into a single stream before
passing it to
a) network layer
b) data link layer
c) application layer
d) physical layer
View Answer
Answer: a
Explanation: None.
2. Which one of the following is a transport layer protocol used in internet?
a) TCP
b) UDP
c) Both (a) and (b)
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
3. User datagram protocol is called connectionless because
a) all UDP packets are treated independently by transport layer
b) it sends data as a stream of related packets
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
4. Transmission control protocol is
a) connection oriented protocol
b) uses a three way handshake to establish a connection
c) recievs data from application as a single stream
d) all of the mentioned
View Answer
Answer: d
Explanation: None.
5. An endpoint of an inter-process communication flow across a computer network is called
a) socket
b) pipe
c) port
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
6. Socket-style API for windows is called
a) wsock
b) winsock
c) wins
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
7. Which one of the following is a version of UDP with congestion control?
a) datagram congestion control protocol
b) stream control transmission protocol
c) structured stream transport
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
8. A _____ is a TCP name for a transport service access point.
a) port
b) pipe
c) node
d) none of the mentioned
View Answer
Answer: a
Explanation: None.
9. Transport layer protocols deals with
a) application to application communication
b) process to process communication
c) node to node communication
d) none of the mentioned
View Answer
Answer: b
Explanation: None.
10. Which one of the following is a transport layer protocol?
a) stream control transmission protocol
b) internet control message protocol
c) neighbor discovery protocol
d) dynamic host configuration protocol
View Answer
Answer: a
Explanation: None.
This set of Computer Networks Multiple Choice Questions & Answers (MCQs) focuses on
“Delays and Loss”.

1. Which of the following delay is faced by the packet in travelling from one end system to
another ?
a) Propagation delay
b) Queuing delay
c) Transmission delay
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
2. For a 10Mbps Ethernet link, if the length of the packet is 32bits, the transmission delay
is(in milliseconds)
a) 3.2
b) 32
c) 0.32
d) None of the mentioned
View Answer
Answer: a
Explanation: Transmission rate = length / transmission rate = 32/10 = 3.2milli seconds.
3. The time required to examine the packet’s header and determine where to direct the
packet is part of
a) Processing delay
b) Queuing delay
c) Transmission delay
d) All of the mentioned
View Answer
Answer: a
Explanation: None.
4. Traffic intensity is given by, where L = number of bits in the packet a = average rate R
= transmission rate
a) La/R
b) LR/a
c) R/La
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
5. In the transfer of file between server and client, if the transmission rates along the path
is 10Mbps, 20Mbps, 30Mbps, 40Mbps. The throughput is usually
a) 20Mbps
b) 10Mbps
c) 40Mbps
d) 50Mbps
View Answer
Answer: b
Explanation: The throughput is generally the transmission rate of bottleneck link.
6. If end to end delay is given by dend-end = N(dproc + dtrans + dprop) is a non
congested network. The number of routers between source and destination is
a) N/2
b) N
c) N-1
d) 2N
View Answer
Answer: c
Explanation: None.
7. The total nodal delay is given by
a) dnodal = dproc – dqueue + dtrans + dprop
b) dnodal = dproc + dtrans – dqueue
c) dnodal = dproc + dqueue + dtrans + dprop
d) dnodal = dproc + dqueue – dtrans – dprop
View Answer
Answer: c
Explanation: None.
8. In a network, If P is the only packet being transmitted and there was no earlier
transmission, which of the following delays could be zero
a) Propogation delay
b) Queuing delay
c) Transmission delay
d) Processing delay
View Answer
Answer: b
Explanation: None.
9. Transmission delay does not depend on
a) Packet length
b) Distance between the routers
c) Transmission rate
d) None of the mentioned
View Answer
Answer: b
Explanation: Transmission delay = packet length / transmission rate
10. Propagation delay depends on
a) Packet length
b) Transmission rate
c) Distance between the routers
d) None of the mentioned
View Answer
Answer: c
Explanation: Propagation delay is the time it takes a bit to propagate from one router to
the next.
1. Which is not a application layer protocol?
a) HTTP
b) SMTP
c) FTP
d) TCP
View Answer
Answer: d
Explanation: TCP is transport layer protocol.
2. The packet of information at the application layer is called __________
a) Packet
b) Message
c) Segment
d) Frame
View Answer
Answer: b
Explanation: For Application, Presentation and Session layers there is no data format for
message. Message is message as such in these three layers. But when it comes to
Transport, Network, Data and Physical layer they have data in format of segments,
packets, frames and bits respectively.
3. Which one of the following is an architecture paradigms?
a) Peer to peer
b) Client-server
c) HTTP
d) Both Peer-to-Peer & Client-Server
View Answer
Answer: d
Explanation: HTTP is a protocol.
4. Application developer has permission to decide the following on transport layer side
a) Transport layer protocol
b) Maximum buffer size
c) Both Transport layer protocol and Maximum buffer size
d) None of the mentioned
View Answer
Answer: c
Explanation: Application layer provides the interface between applications and the
network. So application developer can decide what transport layer to use and what
should be its maximum buffer size.
5. Application layer offers _______ service.
a) End to end
b) Process to process
c) Both End to end and Process to process
d) None of the mentioned
View Answer
Answer: a
Explanation: End to End service is provided in the application layer. Whereas process to
process service is provided at the transport layer.
6. E-mail is _________
a) Loss-tolerant application
b) Bandwidth-sensitive application
c) Elastic application
d) None of the mentioned
View Answer
Answer: c
Explanation: Because it can work with available throughput.
7. Pick the odd one out.
a) File transfer
b) File download
c) E-mail
d) Interactive games
View Answer
Answer: d
Explanation: File transfer, File download and Email are services provided by the
application layer and there are message and data oriented.
8. Which of the following is an application layer service?
a) Network virtual terminal
b) File transfer, access, and management
c) Mail service
d) All of the mentioned
View Answer
Answer: d
Explanation: The services provided by the application layer are network virtual terminal,
file transfer, access and management, mail services, directory services, various file and
data operations.
9. To deliver a message to the correct application program running on a host, the
_______ address must be consulted.
a) IP
b) MAC
c) Port
d) None of the mentioned
View Answer
Answer: c
Explanation: IP address lets you know where the network is located. Whereas MAC
address is a unique address for every device. Port address identifies a process or service
you want to carry on.
10. Which is a time-sensitive service?
a) File transfer
b) File download
c) E-mail
d) Internet telephony
View Answer
Answer: d
Explanation: Internet telephony is Loss-tolerant other applications are not

1. The ____________ translates internet domain and host names to IP address.


a) domain name system
b) routing information protocol
c) network time protocol
d) internet relay chat
View Answer
Answer: a
Explanation: Domain name system is the way the internet domain names are stored and
translated to IP addresses. The domain names systems matches the name of website to
ip addresses of the website.
2. Which one of the following allows a user at one site to establish a connection to
another site and then pass keystrokes from local host to remote host?
a) HTTP
b) FTP
c) Telnet
d) TCP
View Answer
Answer: c
Explanation: Telnet is used for accessing remote computers. Using telnet a user can
access computer remotely. With Telnet, you can log on as a regular user with whatever
privileges you may have been granted to the specific application and data on the
computer.
3. Application layer protocol defines ____________
a) types of messages exchanged
b) message format, syntax and semantics
c) rules for when and how processes send and respond to messages
d) all of the mentioned
View Answer
Answer: d
Explanation: Application layer deals with the user interface, what message is to be sent
or the message format, syntax and semantics. A user has access to application layer for
sending and receiving messages.
4. Which one of the following protocol delivers/stores mail to reciever server?
a) simple mail transfer protocol
b) post office protocol
c) internet mail access protocol
d) hypertext transfer protocol
View Answer
Answer: a
Explanation: SMTP, abbreviation for Simple Mail Transfer Protocol is an application layer
protocol. A client who wishes to send a mail creates a TCP connection to the SMTP
server and then sends the mail across the connection.
5. The ASCII encoding of binary data is called
a) base 64 encoding
b) base 32 encoding
c) base 16 encoding
d) base 8 encoding
View Answer
Answer: a
Explanation: Base64 is used commonly in a number of applications including email via
MIME, and storing complex data in XML. Problem with sending normal binary data to a
network is that bits can be misinterpreted by underlying protocols, produce incorrect data
at receiving node and that is why we use this code.
6. Which one of the following is an internet standard protocol for managing devices on IP
network?
a) dynamic host configuration protocol
b) simple network management protocol
c) internet message access protocol
d) media gateway protocol
View Answer
Answer: b
Explanation: SNMP is a set of protocols for network management and monitoring. This
protocol is included in the application layer. SNMP uses 7 protocol data units.
7. Which one of the following is not an application layer protocol?
a) media gateway protocol
b) dynamic host configuration protocol
c) resource reservation protocol
d) session initiation protocol
View Answer
Answer: c
Explanation: Resource reservation protocol is used in transport layer. It is designed to
reserve resources across a network for quality of service using the integrated services
model.
8. Which protocol is a signaling communication protocol used for controlling multimedia
communication sessions?
a) session initiation protocol
b) session modelling protocol
c) session maintenance protocol
d) resource reservation protocol
View Answer
Answer: a
Explanation: SIP is a signaling protocol in which its function includes initiating,
maintaining and terminating real time sessions. SIP is used for signaling and controlling
multimedia sessions.
9. Which one of the following is not correct?
a) Application layer protocols are used by both source and destination devices during a
communication session
b) HTTP is a session layer protocol
c) TCP is an application layer protocol
d) All of the mentioned
View Answer
Answer: d
Explanation: HTTP is an application layer protocol. Whereas TCP is a transport layer
protocol.
10. When displaying a web page, the application layer uses the _____________
a) HTTP protocol
b) FTP protocol
c) SMTP protocol
d) TCP protocol
View Answer
Answer: a
Explanation: HTTP is abbreviation for hypertext transfer protocol. It is the foundation of
data communication for world wide web. This protocol decides how the message is
formatted and transmitted etc.

1. Transport layer aggregates data from different applications into a single stream before
passing it to
a) network layer
b) data link layer
c) application layer
d) physical layer
View Answer
Answer: a
Explanation: The flow of data in the OSI model flows in following manner Application ->
Presentation -> Session -> Transport -> Network -> Data Link -> Physical.
2. Which one of the following is a transport layer protocol used in networking?
a) TCP
b) UDP
c) Both TCP and UDP
d) None of the mentioned
View Answer
Answer: c
Explanation: Both TCP and UDP are transport layer protocol in networking. TCP is an
abbreviation for Transmission Control Protocol and UDP is an abbreviation for User
Datagram Protocol. TCP is connection oriented whereas UDP is connectionless.
3. User datagram protocol is called connectionless because
a) all UDP packets are treated independently by transport layer
b) it sends data as a stream of related packets
c) it is received in the same order as sent order
d) none of the mentioned
View Answer
Answer: a
Explanation: UDP is an alternative for TCP and it is used for those purposes where
speed matters most whereas loss of data is not a problem. UDP is connectionless
whereas TCP is connection oriented.
4. Transmission control protocol is
a) connection oriented protocol
b) uses a three way handshake to establish a connection
c) recievs data from application as a single stream
d) all of the mentioned
View Answer
Answer: d
Explanation: Major internet applications like www, email, file transfer etc rely on tcp. TCP
is connection oriented and it is optimized for accurate delivery rather than timely delivery.
It can incur long delays.
5. An endpoint of an inter-process communication flow across a computer network is
called
a) socket
b) pipe
c) port
d) none of the mentioned
View Answer
Answer: a
Explanation: Socket is one end point in a two way communication link in the network.
TCP layer can identify the application that data is destined to be sent by using the port
number that is bound to socket.
6. Socket-style API for windows is called
a) wsock
b) winsock
c) wins
d) none of the mentioned
View Answer
Answer: b
Explanation: Winsock is a programming interface which deals with input output requests
for internet applications in windows OS. It defines how windows network software should
access network services.
7. Which one of the following is a version of UDP with congestion control?
a) datagram congestion control protocol
b) stream control transmission protocol
c) structured stream transport
d) none of the mentioned
View Answer
Answer: a
Explanation: The datagram congestion control is a transport layer protocol which deals
with reliable connection setup, teardown, congestion control, explicit congestion
notification, feature negotiation.
8. A _____ is a TCP name for a transport service access point.
a) port
b) pipe
c) node
d) none of the mentioned
View Answer
Answer: a
Explanation: Just as the IP address identifies the computer, the network port identifies
the application or service running on the computer. A port number is 16 bits.
9. Transport layer protocols deals with
a) application to application communication
b) process to process communication
c) node to node communication
d) none of the mentioned
View Answer
Answer: b
Explanation: Transport layer is 4th layer in TCP/IP model and OSI reference model. It
deals with logical communication between process. It is responsible for delivering a
message between network host.
10. Which one of the following is a transport layer protocol?
a) stream control transmission protocol
b) internet control message protocol
c) neighbor discovery protocol
d) dynamic host configuration protocol
View Answer
Answer: a
Explanation: There are many protocols in transport layer. The most prominent are TCP
and UDP. Some of the other protocols are RDP, RUDP, SCTP, DCCP etc.
1. Which page directive should be used in JSP to generate a PDF page?
a) contentType
b) generatePdf
c) typePDF
d) contentPDF
View Answer

2. Which tag should be used to pass information from JSP to included JSP?
a) Using <%jsp:page> tag
b) Using <%jsp:param> tag
c) Using <%jsp:import> tag
d) Using <%jsp:useBean> tag
View Answer
Answer: a
Explanation: <%jsp:param> tag is used to pass information from JSP to included JSP.
3. Application is instance of which class?
a) javax.servlet.Application
b) javax.servlet.HttpContext
c) javax.servlet.Context
d) javax.servlet.ServletContext
View Answer
Answer: d
Explanation: Application object is wrapper around the ServletContext object and it is an
instance of a javax.servlet.ServletContext object.
4. _jspService() method of HttpJspPage class should not be overridden.
a) True
b) False
View Answer
Answer: a
Explanation: _jspService() method is created by JSP container. Hence, it should not be
overridden.
5. Which option is true about session scope?
a) Objects are accessible only from the page in which they are created
b) Objects are accessible only from the pages which are in same session
c) Objects are accessible only from the pages which are processing the same request
d) Objects are accessible only from the pages which reside in same application
View Answer
6. Default value of autoFlush attribute is?
a) true
b) false
View Answer
Answer: a
Explanation: Default value “true” depicts automatic buffer flushing.
7. Which one is the correct order of phases in JSP life cycle?
a) Initialization, Cleanup, Compilation, Execution
b) Initialization, Compilation, Cleanup, Execution
c) Compilation, Initialization, Execution, Cleanup
d) Cleanup, Compilation, Initialization, Execution
View Answer
Answer: c
Explanation: The correct order is Compilation, Initialization, Execution, Cleanup.
advertisement

8. “request” is instance of which one of the following classes?


a) Request
b) HttpRequest
c) HttpServletRequest
d) ServletRequest
View Answer
Answer: c
Explanation: request is object of HttpServletRequest.
9. Which is not a directive?
a) include
b) page
c) export
d) useBean
View Answer
Answer: c
Explanation: Export is not a directive.
10. Which is mandatory in tag?
a) id, class
b) id, type
c) type, property
d) type,id
View Answer
Answer: a
Explanation: The useBean searches existing object and if not found creates an object
using class.
2. The doGet() method in the example extracts values of the parameter’s type and
number by using __________
a) request.getParameter()
b) request.setParameter()
c) responce.getParameter()
d) responce.getAttribute()
View Answer
Answer: a
6. A JSP is transformed into a(n):
a) Java applet
b) Java servlet
c) Either 1 or 2 above
d) Neither 1 nor 2 above
View Answer
Answer: b
8. What programming language(s) or scripting language(s) does Java Server Pages
(JSP) support?
a) VBScript only
b) Jscript only
c) Java only
d) All of the mentioned
View Answer
Answer: c

You might also like