QB (AJPR-Class Test)
QB (AJPR-Class Test)
QB (AJPR-Class Test)
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.
A . Statement
B . PreparedStatement
C .CallableStatement
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.
a) Servlet
b) Server
c) Program
d) Randomize
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
B. i, ii 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
D. JDBC is an API to bridge the object-relational mismatch between OO programs and relational
databases.
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
A.ServerSocket(int port)
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 class is used to create servers that listen for either local client or remote client programs?
A.ServerSockets
B.httpServer
C.httpResponse
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
A. 10
B. B.1024
C. 2048
D. 512