CHAPTER-4:( Networking Basics)
Q. 1 A set of rules that governs data communication:
(a) Protocols (b) Standards
(c) RFCs (d) Functions
Q. 2 A _______is a program providing services to the _____ program.
(a) Server, Client (b) Client, Server
(d) Host, Client (c) Server, Server
Q. 3 Communication using TCP protodcol is ------
(a) connectionless, iterative
(b) connectionless, concurrent
(c) connection-oriented, iterative
(d) connection-oriented, concurrent
Q. 4 Communication using UDP protocol is -------and---------.
(a) connectionless, iterative
(b) connectionless, concurrent
(c) connection-oriented, iterative
(d) connection-oriented, concurrent
Q. 5 -------- is a server that is mediator between real web server
and client application.
(a) Host (b) H'ITP
(c) Proxy (d) Web
Q. 6 SOCK_STREAM sockets are used by --------- processes.
(a) TCP (b) UDP
(c) SCTP (d) FTP
Q. 7 SOCK_DGRAM sockets are used by ---------- processes.
(a) TCP (b) UDP
(c) SCTP (d) FTP
Q. 8 Port number of Telnet is __ .
(a) 21 (b) 23
(d) 79 (c) 25
Q.9 Full form ofDNS is
(a) Data Network Service
(b) Data Name Service
(c) Domain Network Service
(d) Domain Name System
Q.10 What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsUnknownHostException{
4. InetAddress obj1 =InetAddress.getByName("sanfoundary.com");
5. InetAddress obj2 =InetAddress.getByName("sanfoundary.com");
6. boolean x = obj1.equals(obj2);
7. System.out.print(x);
8. }
9. }
a) 0
b) 1
c) true
d) false
Q.11 What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsUnknownHostException{
4. InetAddress obj1 =InetAddress.getByName("cisco.com");
5. InetAddress obj2 =InetAddress.getByName("sanfoundary.com");
6. boolean x = obj1.equals(obj2);
7. System.out.print(x);
8. }
9. }
a) 0
b) 1
c) true
d) false
Q.12. What is the output of this program?
1. Import java.net.*;
2. class networking {
3. public static void main(String[]args) throwsUnknownHostException{
4. InetAddress obj1 =InetAddress.getByName("cisco.com");
5. System.out.print(obj1.getHostName());
6. }
7. }
a) cisco
b) cisco.com
c) www.cisco.com
d) None of the mentioned
Q.13. What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. URLConnection obj1 =obj.openConnection();
6. System.out.print(obj1.getContentType());
7. }
8. }
Note: Host URL is written in html and simple text.
a) html
b) text
c) html/text
d) text/html
Q.14. What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.toExternalForm());
6. }
7. }
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) http://www.sanfoundry.com/javamcq
Q.15.What is the output of this program?
importjava.net.*;
class networking {
publicstaticvoid main(String[]args)throwsMalformedURLException{
URLobj=newURL("http://www.sanfoundry.com/javamcq");
System.out.print(obj.getProtocol());
}
}
a) http
b) https
c) www
d) com
Q.16. What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.getPort());
6. }
7. }
a) 1
b) 0
c) -1
d) garbage value
Q. 17 __ thrown to indicate that the IP address of a host could
not be determined.
(a) UnknownHostException (b) IOException
(c) HostNotFoundException (d) None of these
Q. 18 Which class have only one instance?
(a) Adaptor Class (b) Singleton Class
•
(c) Factory class (d)
·.1 Proxy Class
Q. 19 __ class is necessary to implement datagrams.
(a) DatagramPacket (b) DatagramSocket
(c) Datagram d) Both (a) and (b)
Q. 20 __ method of DatagramPacket is used to find the port
number.
(a) portO
(c) GetPortO
(b) getPortO
(d) findPortO
(d) GetLastModifiedO
Q. 21 __ method is used to know the type of content used in
theURL.
(a) ContenttypeO (b) contentTypeO
(c) getContentTypeO (d) GetContentTypeO
Q. 22 The packages contain classes and interfaces used for input
and output operations of a program is __ .
(a) java.util (b) java.lang
(c) java.io (d) java.file.io
Q.23What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL("http://www.sanfoundry.com/javamcq");
5. System.out.print(obj.getHost());
6. }
7. }
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) http://www.sanfoundry.com/javamcq
Q24.What is the output of this program?
1. importjava.net.*;
2. class networking {
3. publicstaticvoid main(String[]args)throwsMalformedURLException{
4. URLobj=newURL(“http://www.sanfoundry.com/javamcq”);
5. System.out.print(obj.toExternalForm());
6. }
7. }
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) http://www.sanfoundry.com/javamcq
Q25. What does URL stands for?
a) Uniform Resource Locator
b) Uniform Resource Latch
c) Universal Resource Locator
d) Universal Resource Latch
Q26. Which of these exceptions is thrown by URL class’s constructors?
a) URLNotFound
b) URLSourceNotFound
c) MalformedURLException
d) URLNotFoundException
Q27. Which of these is a wrapper around everything associated with a reply from an http server?
a) HTTP
b) HttpResponse
c) HttpRequest
d) httpserver
Q28. Which of these methods is used to know when was the URL last modified?
a) LastModified()
b) getLastModified()
c) GetLastModified()
d) getlastModified()
Q29. Which of these methods is used to know the type of content used in the URL?
a) ContentType()
b) contentType()
c) getContentType()
d) GetContentType()
Q30. Which of these class is necessary to implement datagrams?
a) DatagramPacket
b) DatagramSocket
c) All of the mentioned
d) None of the mentioned
Q31. Which of these method of DatagramPacket is used to find the port number?
a) port()
b) getPort()
c) findPort()
d) recievePort()
Q32. Which class provides system independent server side implementation?
a) Socket
b) ServerSocket
c) Server
d) ServerReader
Q33. Which class represents an Internet Protocol address?
a) InetAddress
b) Address
c) IP Address
d) TCP Address
CHAPTER-5 : (Interacting with Database)
Q.1 JDBC stands for___.
(a) Java Database Connectivity b)Java Database Control
(c)Java Database Components (d) None of these
Q.2 Which statements about JDBC are true ?
(a) JDBC is an API to connect to relational-, object and XML data sources.
(b) JDBC stands for Java DataBase connectivity.
(c) JDBC is an API to access relational databases, spreadsheets and flat files.
(d) JDBC is an API to bridge the object-relational mismatch between OO programs and
relational databases.
Q.3 Which packages contain the JDBC classes ?
(a) java.jdbc and javax.jdbc (b) java.jdbc and java.jdbc.sql
(c) java.sql and javax.sql (d) java.rdb and javax.rdb
Q.4 Which type of driver provides JDBC access via one or more ODBC drivers?
(a) Type 1 driver (b) Type 2 driver
(c) Type 3 driver (d) Type 4 driver
Q.5 Which type of driver converts JDBC calls into the network protocol used by the database
management system directly?
(a) Type 1 driver (b) Type 2 driver
(c) Type 3 driver (d) Type 4 driver
Q.6 Which type of driver of JDBC is called pure driver?
(a) Type 1 driver (b) Type 2 driver
(c) Type 3 driver (d) Type 4 driver
Q.7 Which type of driver of JDBC is called partly Java Driver?
(a) Type 1 driver (b) Type 2 driver
(c) Type 3 driver (d) Type 4 driver
Q.8 Which driver is called as thin-driver in JDBC?
(a) Type-4 driver (b) Type-1 driver
(c) Type-3 driver (d) Type-2 driver
Q.9 Which driver type of JDBC is used in either applet or servlet?
(a) Type 1 and 2 (b) Type 1 and 3
(c) Type 3 and 4. (d) Type 4 only
Q.10 Which of the following is false as far as type 4 driver is concern?
(a) Type 4 driver is "native protocol, pure java” driver
(b) Type 4 drivers are 100 % Java compatible
(c) Type 4 drivers uses socket class to connect to the database.
(d) Type 4 drivers can not be used with Netscape.
Q.11 Which of the following JDBC drivers is known as a partially java driver ?
(a) JOBC-ODBC bridge driver (b) Native-API driver
(c) Network protocol driver (d) Thin driver
Q.12 Which class has strong support of the JDBC architecture ?
(a) The JDBC driver manager (b) The JDBC driver test suite
(c) The JDBC-ODBC bridge (d) All of these
Q.13 Which of the following describes the correct sequence of the steps involved in making
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
Q.14 Which of the following methods are needed for loading a database driver in JDBC?
(a) registerDriver() method (b) Class.forName0
(c) Both a and b (d) getConnection()
Q.15 Which type of statement can execute parameterized queries?
(a) PreparedStatement (b)ParameterizedStatement
(c)CallableStatement (d) All of these
Q.16 What is used to execute parameterized query ?
(a) Statement interface (b) PreparedStatement interface
(c)ResultSet interface (d) None of the above
Q.17 Which of the following encapsulates an SQL statement which is passed to the database to
be parsed, compiled, planned and executed?
(a) DriverManager (b) DBC driver
(c) Connection (d) Statement
Q.18 Which of the following is used to call a stored procedure ?
(a) Statement (b) PreparedStatement
(c) CallableStatmet (d) CalledStatement
Q.19 Database system compiles query when it is____.
(a) executed (b) initialized
(c) prepared (d) invoked
Q.20 To execute a statement, we invoke method _______.
(a) executeUpdate method (b) executeRel method
(c) executeStmt method (d) executeConn method
Q.21 Which JDBC drivers will run your program?
(a) The JDBC-ODBC bridge. (b) The JDBC driver manager.
(c) The JDBC driver test suite. (d) None of the above.
Q.22 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")
Q.23 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”);
Q.24 Which of the following function is used to find the column
count of the particular resultset ?
(a) getMetaData() (b) simple
(c) getColumnCount() (d) parameterized
Q. 25 What is JDBC ?
(a) java compiler (b) Java API
(c) Java interpreter (d) Both (a) and (b)
Q. 26 JDBC is a ______ interface, which means that it is used to invoke SQL commands
directly
(a) low-level (b) middle-level
(c) higher-level (d) user
Q.27 The JDBC-ODBC bridge allows _____ to be used as ____.
(a) JDBC drivers, ODBC drivers (b) Drivers, Application
(c) ODBC drivers, JDBC drivers (d) Application, drivers
Q. 28 Type 1 driver is also known as_____ .
(a) JDBC-Native API (b) JDBC-ODBC Bridge Driver
(c) JDBC-net pure java (d) None of these
Q. 29 Type 2 driver is also known as ______.
(a) JDBC-Native API (b) JDBC-ODBC Bridge Driver
(c) JDBC-net pure java (d) None of these
Q.30 getUserNameO method is used to _____.
(a) retrieve name of user (b) retrieve name
(c) access name (d) None of these
Q. 31 Which of the following query is used for SELECT query ?
(a) execute(); (b) execute(String sql);
(c) executeUpdate(String sql); (d) executeQuery(String sql);
Q.32 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();
Q.33 Which of the following is not interface?
(a) DriverManager (b) Connection
(c) Statement (d) ResultSet
Q.34 There are ____ types of statements
(a)1 (b)2
(c)4 (d)3