QB (AJPR-Class Test)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

1.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

D. JDBC is an API to bridge the object-relational mismatch between OO programs and relational
databases

2.In order to transfer data between a database and an application written in the Java programming
language, the JDBC API provides which of these methods?

A. Methods on the ResultSet class for retrieving SQL SELECT results as Java types.

B. Methods on the PreparedStatement class for sending Java types as SQL statement parameters.

C. Methods on the CallableStatement class for retrieving SQL OUT parameters as Java types.

D. All mentioned above

3.Which of the following is efficient than statement due to pre-compilation of SQL?

A . Statement

B . PreparedStatement

C .CallableStatement

D.Non Of The Above

4.Which of the following is first step to create a JDBC application?

A - Import packages containing the JDBC classes needed for database programming.

B - Register the JDBC driver, so that you can open a communications channel with the database.

C - Open a connection using the DriverManager.getConnection () method.

D - Execute a query using an object of type Statement.

5. The Java __________ specification defines an application programming interface for


communication between the Web server and the application program.

a) Servlet

b) Server

c) Program

d) Randomize

6.How many JDBC driver types does Sun define?

A.One

B.Two

C.Three
D.Four

7.What is the difference between servlets and applets?i. Servlets execute on Server; Applets execute
on browser ii. Servlets have no GUI; Applet has GU Iiii. Servlets creates static web pages;
Applets creates dynamic web pages iv. Servlets can handle only a single request; Applet can
handle multiple requests

A. i, ii, iii are correct

B. i, ii are correct

C. i, iii are correct

D. i, ii, iii, iv are correct

8.Which of the following code is used to get an attribute in a HTTP Session object in servlets?

a) session.getAttribute(String name)

b) session.alterAttribute(String name)

c) session.updateAttribute(String name)

d) session.setAttribute(String name)

9.Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application
A.True
B.False
10. SessionIDs are stored in cookies.
A.True
B.False
11.The sendRedirect() method of HttpServletResponse interface can be used to redirect response to
another resource, it may be servlet, jsp or html file.
A.True
B.False
12.What is fullform of CGI?
A) Common Gate interference
(B) Common Gateway Interface
(C) Common Gateway Intercept
(D) None of Above
13.Which of following is/are steps for servlet life cycle?
(A) Servlet class is loaded
(B) Servlet instance is created
(C) init,Service,destroy method is invoked
(D) All of Above
14.Which of the following is true about init() method of servlet?
(A) It is not called again and again for each user request.
(B) It simply creates or loads some data that will be used throughout the life of the servlet.
(C) Both A & B
(D) None of Above
15.Which of the following is true about destroy() method of servlet?
(A) It is called only once.
(B) Servlet object is marked for garbage collection after called destroy() method.
(C) The servlet is terminated by calling the destroy() method.
(D) All of Above
16.Which of following ways to create servlet?
(A) Using GenericServlet class
(B) Using Servlet Interface
(C) Using HttpServlet class
(D) All of Above
17. 17.The performance of the application will be faster if you use PreparedStatement interface
because query is compiled only once.
A. True
B.False
18.The ResultSet.next method is used to move to the next row of the ResultSet, making it the current
row.
A. True
B.False
19.How many steps are used to connect any java application using JDBC?
A.5
B.4
C.3
D.6
20. Which model does a Java applet or application talks directly to the data source?
A. Two-tier models
B. Three-tier models
C.Both A & B
D. None of the above
21.What is the reason that a java program cannot directly communicate with an ODBC driver?
A. ODBC written in C# language
B. ODBC written in C language
C. ODBC written in C++ language
D. None of the above
22.Which driver uses ODBC driver to connect to the database?
A. JDBC-ODBC bridge driver
B. Native - API driver
C. Network Protocol driver
D. Thin driver
23. What will be the output of the following Java program? import java.net.*;
class networking { public static void main(String[] args) throws Exception { URL
obj = new URL("https://www.sanfoundry.com/javamcq"); URLConnection obj1 =
obj.openConnection(); System.out.print(obj1.getContentType()); } }
A. html
B. text
C. html/text
D. text/html
24.try (Connection conn = DriverManager.getConnection(url); Statement stmt =
conn.createStatement()) { conn.setAutoCommit(false); stmt.executeUpdate("insert into colors
values ('red')"); stmt.executeUpdate("insert into colors values ('blue')"); conn.commit();
conn.setAutoCommit(true); stmt.executeUpdate("insert into colors values ('green')");}
A.None
B.One
C.Two
D.Three
25.What will be the output of the following Java program?import java.net.*; class networking {
public static void main(String[] args) throws MalformedURLException { URL obj = new
URL("https://www.sanfoundry.com/javamcq"); System.out.print(obj.toExternalForm()); }
}
a) sanfoundry
b) sanfoundry.com
c) www.sanfoundry.com
d) https://www.sanfoundry.com/javamcq
27. What is the lifecycle of a servlet ?
A.Servlet class is loaded
B.Servlet instance is created
C.init, a.Service, destroy methodis invoked
D.All of these

28 .What is the difference between servlet and applet?


A.servlets execute on servers
while applets execute on
browser
B.servlets create static pages
while applets create dynamic
pages
C.servlets can execute single
request while applets execute
multiple requests
D.None of these

29 A deployment descriptor describes


A.web component response settings
B.web component settings
C. web component request settings
D.All of these

30.Which object is created by the web container at time of deploying


the project?
A.ServletConfig
B.ServletContext
C,Both a and b
D. None of the above

31.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.

32.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

33. What is the output of this program ? import java.net. *; class networking { public static void
main(String() args) throws UnknownHostException { InetAddress objl =
InetAddress.getByName("www.google.com"); InetAddress obj2 =
InetAddress.getByName(..www.google.com"); boolean x = obj1.equals(obj2); System.out.print(x); } }

A.O

B.1

C.TRUE

D.FALSE

34. 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

35. The correct way of using ServerSocket is__ .

A.ServerSocket(int port)

B.ServerSocket(int port, int maxQueue)

C.ServerSocket(int port, int maxQueue, InetAddress IocatAddress)

D.All of these

36.Which package contains the classes and interfaces required for Java networking?

A.java.io

B.java.util

C.java.net
D. java.awt

37. 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

37. 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

38.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

39. 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

40 How many ports of TCP/IP are reserved for specific protocols?

A. 10
B. B.1024
C. 2048
D. 512

You might also like