300+ TOP Advanced Java MCQs and Answers Quiz Exam

Advanced JAVA Multiple Choice Questions Pdf

ajp mcq with answer
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

Answer: D. java.util.datetime

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

Answer: D. better performance

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

Answer: C. prevents 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

Answer: A. java.sql.timestamp

5. What does setAutoCommit(false) do?

A. commits transweraction after each query
B. explicitly commits transweraction
C. does not commit transweraction automatically after each query
D. never commits transweraction

Answer: C. does not commit transweraction automatically after each query

6. Which of the following is used to call stored procedure?

A. statement
B. preparedstatement
C. callablestatment
D. calledstatement

Answer: C. callablestatment

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

A. setbatch()
B. deletebatch()
C. removebatch()
D. addbatch()

Answer: D. addbatch()

8. Which of the following is used to rollback a JDBC trAnsweraction?

A. rollback()
B. rollforward()
C. deletetransweraction()
D. removetransweraction()

Answer: A. rollback()

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

Answer: A. jdbc-odbc bridge driver

10. How many JDBC product components does the Java software provides?

A. 3
B. 2
C. 4
D. 5

Answer: A. 3

Advanced Java MCQs

11. How many types of JDBC drivers are available?
A. 3

B. 4

C. 2

D. 5

Answer: B. 4

12. Which result set generally does not show changes to the underlying database that are made while it is open. The membership, order, and column values of rows are typically fixed when the result set is created?
A. type_forward_only

B. type_scroll_insensitive

C. type_scroll_sensitive

D. all mentioned above

Answer: B. type_scroll_insensitive

13. Which method is used for an SQL statement that is executed frequently?
A. prepare statement

B. prepare call

C. create statement

D. none of the above

Answer: A. prepare statement

14. What is used to execute parameterized query?
A. statement interface

B. preparedstatement interface

C. resultset interface

D. none of the above

Answer: B. preparedstatement interface

15. Which JDBC product components does the Java software provide?
A. the jdbc driver manager

B. the jdbc driver test suite

C. the jdbc-odbc bridge

D. all mentioned above

Answer: D. all mentioned above

16. JDBC stands for?
A. java database connectivity

B. java database concept

C. java database communications

D. none of the above

Answer: A. java database connectivity

17. Which of the following allows non repeatable read in JDBC Connection?
A. transweraction_read_uncommitted

B. transweraction_read_committed

C. transweraction_serializable

D. transweraction_repeatable_read

Answer: D. transweraction_repeatable_read

18. Which of the following statements is false as far as different type of statements is concern in JDBC?
A. regular statement

B. prepared statement

C. callable statement

D. interim statement

Answer: D. interim statement

19. Which of the following methods are needed for loading a database driver in JDBC?
A. registerdriver() method

B. class.forname()

C. both a and b

D. getconnection()

Answer: C. both a and b

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

Answer: D. type 4 drivers can not be used with netscape

21. Which driver is efficient and always preferable for using JDBC applications?
A. type – 4

B. type – 1

C. type – 3

D. type – 2

Answer: A. type – 4

22. JDBC facilitates to store the java objects by using which of the methods of PreparedStatement setObject () 2. setBlob() 3. setClob()
A. 1, 2

B. 1,2,3

C. 1,3

D. 2,3

Answer: B. 1,2,3

23. The JDBC-ODBC bridge is
A. three tiered

B. multithreaded

C. best for any platform

D. all of the above

Answer: B. multithreaded

24. All raw data types (including binary documents or images) should be read and uploaded to the database as an array of
A. byte

B. int

C. boolean

D. char

Answer: A. byte

25. The class java sql.Timestamp has its super class as
A. java sql.time

B. java util.date

C. java util.time

D. none of the above

Answer: B. java)util.date

26. BLOB, CLOB, ARRAY and REF type columns can be updated in
a. jdbc 1.0

b. jdbc 4.0

c. jdbc 2.0

d. jdbc 3.0

Answer: d. jdbc 3.0

27. Which of the following methods finds the maximum number of connections that a specific driver can obtain?
a. database.getmaxconnections

b. connection.getmaxconnections

c. databasemetadata)getmaxconnections

d. resultsetmetadata)getmaxconnections

Answer: c. databasemetadata)getmaxconnections

28. When the message “No Suitable Driver” occurs?
a. when the driver is not registered by class.forname() method

b. when the user name, password and the database does not match

c. when the jdbc database url passed is not constructed properly

d. when the type 4 driver is used

Answer: c. when the jdbc database url passed is not constructed properly

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

Answer: a. type-4 driver

30. How many trAnsweraction isolation levels are defined in javA)sql.Connection interface?
a. 4

b. 3

c. 5

d. 2

Answer: c. 5

31. Which method is used to perform DML statements in JDBC?
a. execute()

b. executequery()

c. executeupdate()

d. executeresult()

Answer: c. executeupdate()

32. What is the disadvantage of Type-4 Native-Protocol Driver?
a. at client side, a separate driver is needed for each database.

b. type-4 driver is entirely written in java

c. the driver converts jdbc calls into vendor-specific database protocol

d. it does not support to read mysql data)

Answer: a. at client side, a separate driver is needed for each database.

33. TCP,FTP,Telnet,SMTP are example of?
a. socket

b. ip address

c. protocol

d. mac address

Answer: c. protocol

34. In Inetaddress class which method returns the host name of IP address?
a. public string gethostname()

b. public string gethostaddress()

c. public string inetaddress getlocalhost()

d. none

Answer: a. public string gethostname()

35. Show some networking terminology given below?
a. all

b. ip address

c. protocol

d. mac address

Answer: a. all

36. Which classes are used for connection less socket programming?
a. datagram socket

b. datagram packet

c. both a and b

d. none

Answer: c. both a and b

37. how many ports TCP/IP are reserved for specific protocol?
a. 10

b. 1024

c. 2048

d. 512

Answer: b. 1024

38. how many bits are in a single IP address?
a. 8

b. 16

c. 32

d. 64

Answer: c. 32

39. Which of these class is used to encapsulate IP address and DNS?
a. datagram packet

b. url

c. inetaddress

d. contenthandler

Answer: c. inetaddress

40. Which of these is return type of getAddress method of DatagramPacket class?
a. findaddress()

b. getaddress()

c. address()

d. whois()

Answer: b. getaddress()

41. Which of these method of DatagramPacket is used to find port number?
a. port()

b. getport()

c. findport()

d. receivedport()

Answer: a. port()

42. Which of these class is necessary to implement datagrams? DNYANSAGAR ARTS AND COMMERCE COLLEGE, BALEWADI,PUNE – 45 PROF . SUPRIYA MANE www.dacc.edu.in
a. datagrampacket

b. datagramsocket

c. all of the mentioned

d. none of the mentioned

Answer: c. all of the mentioned

43. Which of these method of DatagramPacket is used to find the port number?
a. port()

b. getport()

c. findport()

d. recieveport()

Answer: a. port()

44. Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?
a. getdata()

b. getbytes()

c. getarray()

d. recievebytes()

Answer: a. getdata()

45. Which of these method of DatagramPacket is used to find the length of byte array?
a. getnumber()

b. length()

c. length()

d. getlength()

Answer: d. getlength()

46. Which of these method is used to start a server thread?
a. run()

b. start()

c. runthread()

d. startthread()

Answer: a. run()

47. Which of these method is called when http daemon is acting like a normal web server?
a. handle()

b. handleget()

c. handleget()

d. handleget()

Answer: c. handleget()

48. Which of these methods of httpd class is used to read data from the stream?
a. getdta()

b. getresponse()

c. getstream()

d. getrawrequest()

Answer: d. getrawrequest()

49. Which of these method of httpd class is used to get report on each hit to HTTP server?
a. log()

b. logentry()

c. loghttpd()

d. logresponse()

Answer: b. logentry()

50. Which of these method is used to find a URL from the cache of httpd?
a. findfromcache()

b. findfromcache()

c. servefromcache()

d. getfromcache()

Answer: c. servefromcache()

51. Which of these variables stores the number of hits that are successfully served out of cache?
a. hits

b. hitstocache

c. hits_to_cache

d. hits.to.cache

Answer: d. hits.to.cache

52. Which of these method of httpd class is used to write UrlCacheEntry object into local disk?
a. writediskcache()

b. writetodisk()

c. writecache()

d. writediskentry()

Answer: a. writediskcache()

53. Which of these is an instance variable of class httpd?
a. port

b. cache

c. log

d. all of the mentioned

Answer: d. all of the mentioned

54. Which of these is an instance variable of httpd that is a Hashtable?
a. port

b. cache

c. log

d. stopflag

Answer: c. log

55. Which of these exception is thrown by URL class’s constructors?
a. urlnotfound

b. urlsourcenotfound

c. malformedurlexception

d. urlnotfoundexception

Answer: c. malformedurlexception

56. Which of these methods is used to know host of an URL?
a. host()

b. gethost()

c. gethost()

d. gethost()

Answer: b. gethost()

57. Which of these methods is used to know the full URL of an URL object?
a. fullhost()

b. gethost()

c. externalform()

d. toexternalform()

Answer: d. toexternalform()

58. Which of these class is used to access actual bits or content information of a URL?
a. url

b. urldecoder

c. urlconnection

d. all of the mentioned

Answer: d. all of the mentioned

59. Which object of HttpSession can be used to view and manipulate information about a session?
a. session identifier

b. creation time

c. last accessed time

d. all mentioned above

Answer: d. all mentioned above

60. Which of these ways used to communicate from an applet to servlet?
a. rmi communication

b. http communication

c. socket communication

d. all mentioned above

Answer: d. all mentioned above

61. Which methods are used to bind the objects on HttpSession instance andget the objects?
a. setattribute

b. getattribute

c. both a & b

d. none of the above

Answer: c. both a & b

62. Which type of ServletEngine is a server that includes built-in support for servlets?
a. add-on servletengine

b. embedded servletengine

c. standalone servletengine

d. none of the above

Answer: c. standalone servletengine

63. What type of servlets use these methods doGet(), doPost(),doHead, doDelete(), doTrace()?
a. genereic servlets

b. httpservlets

c. all of the above

d. none of the above

Answer: b. httpservlets

64. Which cookie it is valid for single session only and it is removed each time when the user closes the browser?
a. persistent cookie

b. non-persistent cookie

c. all the above

d. none of the above

Answer: b. non-persistent cookie

65. Which action tags are used in JSP for developing web application with Java Bean?
a. jsp:usebean

b. jsp:setproperty

c. jsp:getproperty

d. both b & c

Answer: d. both b & c

66. Which technology do we mix our business logic with the presentation logic?
a. servlet

b. jsp

c. both a & b

d. none of the above

Answer: a. servlet

67. Which tag is used to execute java source code in JSP?
a. declaration tag

b. scriptlet tag

c. expression tag

d. none of the above

Answer: b. scriptlet tag

68. Which JSP Action tags is used to include the content of another resource,it May be jsp, html or servlet?
a. jsp:include

b. jsp:forward

c. jsp:plugin

d. jsp:papam

Answer: a. jsp:include

69. In JSP how many ways are there to perform exception handling?
a. 3

b. 2

c. 4

d. 5

Answer: b. 2

70. In JSP page directive which attribute defines theMIME(Multipurpose Internet Mail Extension) type of the HTTP response?
a. import

b. content type

c. extends

d. info

Answer: b. content type

71. A JSP page consists of which tags?
a. html tags

b. jsp tags

c. both a & b

d. none of the above

Answer: c. both a & b

72. What alternatives exist to embedding Java code directly within the HTML markup of your JSP page?
a. moving the code into your session manager.

b. moving the code into scriptlets.

c. moving the code into javabeans and servlets.

d. moving the code into a transaction manager.

Answer: c. moving the code into javabeans and servlets.

73. What type of scriptlet code is better-suited to being factored forward into a servlet?
a. code that deals with logic that is common across requests.

b. code that deals with logic that is vendor specific)

c. code that deals with logic that relates to database access.

d. code that deals with logic that relates to client scope.

Answer: a. code that deals with logic that is common across requests.

74. URL encoding is the method of replacing all the spaces and other extra characters into their corresponding _______ Characters?
a. hex

b. binary

c. octal

d. decimal

Answer: a. hex

75. Which of the scripting of JSP not putting content into service method of the converted servlet?
a. declarations

b. scriptlets

c. expressions

d. none of the above

Answer: a. declarations

76. What requires less resources?
a. thread

b. process

c. thread and process

d. neither thread nor process

Answer: a. thread

77. What does not prevent JVM from terminating?
a. process

b. daemon thread

c. user thread

d. jvm thread

Answer: b. daemon thread

78. What decides thread priority?
a. process

b. process scheduler

c. thread

d. thread scheduler

Answer: d. thread scheduler

79. What should not be done to avoid deadlock?
a. avoid using multiple threads

b. avoid hold several locks at once

c. execute foreign code while holding a lock

d. use interruptible locks

Answer: c. execute foreign code while holding a lock

80. What is true about threading?
a. run() method calls start() method and runs the code

b. run() method creates new thread

c. run() method can be called directly without start() method being called

d. start() method creates new thread and calls code written in run() method

Answer: d. start() method creates new thread and calls code written in run() method

81. Which of the following is a correct constructor for thread?
a. thread(runnable a, string str)

b. thread(int priority)

c. thread(runnable a, int priority)

d. thread(runnable a, threadgroup t)

Answer: a. thread(runnable a, string str)

82. Which of the following will ensure the thread will be in running state?
a. yield()

b. notify()

c. wait()

d. thread.killthread()

Answer: c. wait()

83. Which of these are types of multitasking?
a. process based

b. thread based

c. process and thread based

d. none of the mentioned

Answer: c. process and thread based

84. What will happen if two thread of the same priority are called to be processed simultaneously?
a. anyone will be executed first lexographically

b. both of them will be executed simultaneously

c. none of them will be executed

d. it is dependent on the operating system

Answer: d. it is dependent on the operating system

85. In a RMI Client Program, what are the exceptions which might have to handled?
a. remoteexception

b. notboundexception

c. malformedurlexception

d. all mentioned above

Answer: d. all mentioned above

86. Which is a one-way communication only between the client and the server and it is not a reliable and there is no confirmation regarding reaching the message to the destination?
a. tcp/ip

b. udp

c. both a & b

d. none of the above

Answer: b. udp

87. An RMI Server is responsible for,
a. creating an instance of the remote object

b. exporting the remote object

c. binding the instance of the remote object to the rmi registry

d. all mentioned above

Answer: d. all mentioned above

88. In RMI Distributed object applications need to do?
a. locate remote objects

b. communicate with remote objects

c. load class definitions for objects that are passed around

d. all mentioned above

Answer: d. all mentioned above

89. In RMI applications which program obtains a remote reference to one or more remote objects on a server and then invokes methods on them?
a. server

b. client

c. both a & b

d. none of the above

Answer: b. client

90. Which package is used for Remote Method Invocation (RMI)?
a. java.lang.rmi

b. java.lang.reflect

c. java.applet

d. java.rmi

Answer: d. java.rmi

91. Java supports RMI, RMI Stands for?
a. random method invocation

b. remote memory interface

c. remote method invocation

d. random method invocation

Answer: c. remote method invocation

92. Which is built on the top of socket programming?
a. ejb

b. rmi

c. both a & b

d. none of the above

Answer: b. rmi

93. Which of these package contains classes and interfaces for networking?
A. java.io

B. java.util

C. java.net

D. javax.swing

Answer: C. java.net

94. In the following URL, identify the protocol identifier? https ://gtu.ac.in:8080/course.php
A. http

B. gtu.ac.in

C. //gtu.ac.in:80/course.php

D. 8080

Answer: A. http

95. Which of the following protocol follows connection less service?
A. TCP

B. TCP/IP

C. UDP

D. HTTP

Answer: C. UDP

96. Which of the following statement is NOT true?
A. TCP is a reliable but slow.

B. UDP is not reliable but fast.

C. File Transfer Protocol (FTP) is a standard Internet protocol for transmitting files between computers on the Internet over TCP/IP connections.

D. In HTTP, all communication between two computers are encrypted

Answer: D. In HTTP, all communication between two computers are encrypted

97. Which of the following statement is TRUE?
A. With stream sockets there is no need to establish any connection and data flows between the processes are as continuous streams.

B. Stream sockets are said to provide a connection-less service and UDP protocol is used

C. Datagram sockets are said to provide a connection-oriented service and TCP protocol is used

D. With datagram sockets there is no need to establish any connection and data flows between the processes are as packets.

Answer: D. With datagram sockets there is no need to establish any connection and data flows between the processes are as packets.

98. Which of the following method call is valid to obtain the server’s host name by invoking an applet?
A. getCodeBase().host()

B. getCodeBase().getHost()

C. getCodeBase().hostName()

D. getCodeBase().getHostName()

Answer: B. getCodeBase().getHost()

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

Answer: B. Socket s = serverSocket.accept()

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

Answer: A. Socket s = new Socket(ServerName, port);

101. To connect to a server running on the same machine with the client, which of the following cannotbe used for the hostname?
A. “localhost”

B. “127.0.0.1”

C. InetAddress.getLocalHost(),

D. “127.0.0.0”

Answer: D. “127.0.0.0”

102. In the socket programming, for an IP address, which can be used to find the host name and IP address of a client/ server?
A. The ServerSocket class

B. The Socket class

C. The InetAddress class

D. The Connection interface

Answer: C. The InetAddress class

103. To create an InputStream on a socket, say s, which of the following statement is necessary?
A. InputStream in = new InputStream(s);

B. InputStream in = s.getInputStream();

C. InputStream in = s.obtainInputStream();

D. InputStream in = s.getStream();

Answer: B. InputStream in = s.getInputStream();

104. Which of the following protocols is/are for splitting and sending packets to an address across a network?
A. TCP/IP

B. FTP

C. SMTP

D. UDP

Answer: A. TCP/IP

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

Answer: A. TCP/IP

106. Which of these class is used to encapsulate IP address and DNS?
A. DatagramPacket

B. URL

C. InetAddress

D. ContentHandler

Answer: C. InetAddress

107. Which of the following type of JDBC driver, is also called Type 2 JDBC driver?
A. JDBC-ODBC Bridge plus ODBC driver

B. Native-API, partly Java driver

C. JDBC-Net, pure Java driver

D. Native-protocol, pure Java driver

Answer: B. Native-API, partly Java driver

108. Which of the following type of JDBC driver, is also called Type 1 JDBC driver?
A. JDBC-ODBC Bridge plus ODBC driver

B. Native-API, partly Java driver

C. JDBC-Net, pure Java driver

D. Native-protocol, pure Java driver

Answer: A. JDBC-ODBC Bridge plus ODBC driver

109. Which of the following holds data retrieved from a database after you execute an SQL query using Statement objects?
A. ResultSet

B. JDBC driver

C. Connection

D. Statement

Answer: A. ResultSet

110. Which of the following is not a valid type of ResultSet?
A. ResultSet.TYPE_FORWARD_ONLY

B. ResultSet.TYPE_SCROLL_INSENSITIVE

C. ResultSet.TYPE_SCROLL_SENSITIVE

D. ResultSet.TYPE_BACKWARD_ONLY

Answer: D. ResultSet.TYPE_BACKWARD_ONLY

111. Which of the following type of JDBC driver, uses database native protocol?
A. JDBC-ODBC Bridge plus ODBC driver

B. Native-API, partly Java driver

C. JDBC-Net, pure Java driver

D. Native-protocol, pure Java driver

Answer: D. Native-protocol, pure Java driver

112. What is JDBC?
A. JDBC is a java based protocol.

B. JDBC is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.

C. JDBC is a specification to tell how to connect to a database.

D. Joint Driver for Basic Connection

Answer: B. JDBC is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.

113. Which of the following manages a list of database drivers in JDBC?
A. DriverManager

B. JDBC driver

C. Connection

D. Statement

Answer: A. DriverManager

114. Which of the following type of JDBC driver should be used if your Java application is accessing multiple types of databases at the same time?
A. Type 1

B. Type 2

C. Type 3

D. Type 4

Answer: C. Type 3

115. Which of the following is correct about JDBC?
A. JDBC architecture decouples an abstraction from its implementation.

B. JDBC follows a bridge design pattern.

C. Both of the above.

D. None of the above.

Answer: C. Both of the above.

116. Which of the following step establishes a connection with a database?
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.

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

117. Which of the following is true about JDBC?
A. The JDBC API is an API to access different relational databases.

B. You use it to access relational databases without embedding a dependency on a specific database type in your code.

C. JDBC stands for Java DataBase Connectivity.

D. All of the above.

Answer: D. All of the above.

118. How many Result sets available with the JDBC 2.0 core API?
A. 2

B. 3

C. 4

D. 5

Answer: B. 3

119. Which method is used to establish the connection with the specified url in a Driver Manager class?
A. public static void registerDriver(Driver driver)

B. public static void deregisterDriver(Driver driver)

C. public static Connection getConnection(String url)

D. public static Connection getConnection(String url,String userName,String password)

Answer: C. public static Connection getConnection(String url)

120. Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?
A. JDBC-Net

B. JDBC-ODBC bridge

C. Native API as basis

D. Native protocol as basis

Answer: A. JDBC-Net

121. JDBC RowSet is the wrapper of ResultSet,It holds tabular data like ResultSet but it is easy and flexible to use.
A. True

B. False

C. none

D. all

Answer: A. True

122. The ResultSet.next method is used to move to the next row of the ResultSet, making it the
current row.
A. True

B. False

C. none

D. all

Answer: A. True

123. Which JDBC product components does the Java software provide?
A. The JDBC driver manager

B. The JDBC driver test suite

C. The JDBC-ODBC bridge

D. All mentioned above

Answer: D. All mentioned above

124. Which class has traditionally been the backbone of the JDBC architecture?
A. the JDBC driver manager

B. the JDBC driver test suite

C. the JDBC-ODBC bridge

D. All mentioned above

Answer: A. the JDBC driver manager

125. Which was the first most widely used programming interface for accessing relational databases and it offers the ability to connect all the databases on all the platforms.?
A. JDBC API

B. ODBC API

C. Both A & B

D. None of the above

Answer: B. ODBC API

126. JDBC is a Java API that is used to connect and execute query to the database
A. True

B. False

C. none

D. all

Answer: A. True

127. In the following JDBC drivers which is known as fully java driver?
A. Native-API driver

B. Network Protocol driver

C. Thin driver

D. Both B & C

Answer: D. Both B & C

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

Answer: C. The JDBC driver test suite

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

Answer: B. ODBC written in C language

130. A leading database connectivity vendor, worked together to produce the ____.
A. JDBC-ODBC Bridge

B. JDBC Driver Test Suite

C. Both A & B

D. None of the above

Answer: C. Both A & B

131. Which driver converts JDBC calls directly into the vendor-specific database protocol?
A. Native – API driver

B. Network Protocol driver

C. Thin driver

D. Both B & C

Answer: C. Thin driver

132. Which models do the JDBC API support for the database access?
A. Two-tier models

B. Three-tier models

C. Both A & B

D. None of the above

Answer: C. Both A & B

133. Which of the following JDBC drivers is known as a partially java driver?
A. JDBC-ODBC bridge driver

B. Native-API driver

C. Network Protocol driver

D. Thin driver

Answer: B. Native-API driver

134. The JDBC API is what allows access to a data source from a Java middle tier
A. True

B. False

C. none

D. all

Answer: A. True

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

Answer: A. JDBC-ODBC bridge driver

136. How many JDBC product components does the Java software provides?
A. 3

B. 2

C. 4

D. 5

Answer: A. 3

137. How many types of JDBC drivers are available?
A. 3

B. 4

C. 2

D. 5

Answer: B. 4

138. Which method is used for an SQL statement that is executed frequently?
A. prepareStatement

B. prepareCall

C. createStatement

D. None of the above

Answer: A. prepareStatement

Servlet and Overview

139. How is the dynamic interception of requests and responses to transform the information done?
A. servlet container

B. servlet config

C. servlet context

D. servlet filter

Answer: D. servlet filter

140. Which type of ServletEngine is a server that includes built-in support for servlets?
A. Add-on ServletEngin

B. Embedded ServletEngine

C. Standalone ServletEngine

D. None of the above

Answer: C. Standalone ServletEngine

141. What type of servlets use these methods doGet(), doPost(),doHead, doDelete(), doTrace()?
A. Genereic Servlets

B. HttpServlets

C. All of the above

D. None of the above

Answer: B. Http Servlets

142. Which cookie it is valid for single session only and it is removed each time when the user closes the browser?
A. Persistent cookie

B. Non-persistent cookie

C. All the above

D. None of the above

Answer: B. Non-persistent cookie

143. Sessions is a part of the SessionTracking and it is for maintaining the client state at server side.
A. True

B. False

C. none

D. all

Answer: A. True

144. When destroy() method of a filter is called?
A. The destroy() method is called only once at the end of the life cycle of a filter

B. The destroy() method is called after the filter has executed doFilter method

C. The destroy() method is called only once at the begining of the life cycle of a filter

D. The destroyer() method is called after the filter has executed

Answer: A. The destroy() method is called only once at the end of the life cycle of a filter

145. Web server is used for loading the init() method of servlet.
A. True

B. False

C. none

D. all

Answer: A. True

146. Servlets handle multiple simultaneous requests by using threads.
A. True

B. False

C. none

D. all

Answer: A. True

147. Which method is used to send the same request and response objects to another servlet in RequestDispacher ?
A. forward()

B. sendRedirect()

C. Both A & B

D. None of the above

Answer: A. forward()

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

C. none

D. all

Answer: A. True

149. Which packages represent interfaces and classes for servlet API?
A. javax.servlet

B. javax.servlet.http

C. Both A & B

D. None of the above

Answer: C. Both A & B

150. Which class can handle any type of request so that it is protocol-independent?
A. GenericServlet

B. HttpServle

C. Both A & B

D. None of the above

Answer: A. GenericServlet

151. Which HTTP Request method is non-idempotent?
A. GET

B. POST

C. Both A & B

D. None of the above

Answer: C. Both A & B

152. Which object is created by the web container at time of deploying the project?
A. ServletConfig

B. ServletContext

C. Both A & B

D. None of the above

Answer: B. ServletContext

153. What is the lifecycle of a servlet?
A. Servlet class is loaded

B. Servlet instance is created

C. init,Service,destroy method is invoked

D. All mentioned above

Answer: D. All mentioned above

154. Which method in session tracking is used in a bit of information that is sent by a web server to a browser and which can later be read back from that browser?
A. HttpSession

B. URL rewriting

C. Cookies

D. Hidden form fields

Answer: C. Cookies

155. Which are the examples of Application Server?
A. Apache

B. Tomcat

C. JBoss

D. Weblogic

Answer: C. JBoss

156. How many techniques are used in Session Tracking?
A. 4

B. 3

C. 2

D. 5

Answer: A. 4

157. In HTTP Request method Get request is secured because data is exposed in URL bar
A. True

B. False

C. none

D. all

Answer: B. False

158. In the following statements identify the disadvantages of CGI?
A. If number of clients increases, it takes more time for sending response

B. For each request, it starts a process and Web server is limited to start processes

C. It uses platform dependent language e.g. C, C++, perl

D. All mentioned above

Answer: D. All mentioned above

159. Servlet technology is used to create web application
A. True

B. False

C. none

D. all

Answer: A. True

160. Which method is used to specify before any lines that uses the PintWriter?
A. setPageType()

B. setContextType()

C. setContentType()

D. setResponseType()

Answer: C. setContentType()

161. What are functions of Servlet container?
A. Lifecycle management

B. Communication Support

C. Multithreading Support

D. All of the above

Answer: D. All of the above

162. Which object of Http Session can be used to view and manipulate information about a session?
A. session identifier

B. creation time

C. last accessed time

D. All mentioned above

Answer: D. All mentioned above

163. Which methods are used to bind the objects on HttpSession instance and get the objects?
A. setAttribute

B. getAttribute

C. Both A & B

D. None of the above

Answer: C. Both A & B

164. Which method take a string not a URL?
A. sendRedirect

B. forward

C. Both

D. None

Answer: A. sendRedirect

165. Which of the following are interface?

  1. ServletContext
  2. Servlet
  3. GenericServlet
  4. HttpServlet

A. 1,2,3,4

B. 1,2

C. 1,2,3

D. 1,4

Answer: B. 1,2

166. The life cycle of a servlet is managed by
A. servlet context

B. servlet container

C. the supporting protocol (such as http or https)

D. All of the above

Answer: B. servlet container

167. 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)

Answer: A. session.getAttribute(String name)

168. What is the difference between servlets and applets?
i. Servlets execute on Server; Applets execute on browser ii. Servlets have no GUI; Applet has GUI iii. 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

Answer: B. i, ii are correct

169. Which are the session tracking techniques?
i. URL rewriting ii. Using session object iii.Using response object iv. Using hidden fields v. Using cookies vi. Using servlet object
A. i, ii, iii, vi

B. i, ii, iv, v

C. i, vi, iii, v

D. i, ii, iii, v

Answer: B. i, ii, iv, v

170. A deployment descriptor describes
A. Web component response settings

B. Web component setting

C. Web component request objects

D. All of the above

Answer: B. Web component setting

171. The values of and in web.xml file
A. must be same

B. must not be same

C. may be same

D. None of the above

Answer: C. may be same

JSP

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

Answer: C. Compilation, Initialization, Execution, Cleanup

173. Which technology do we mix our business logic with the presentation logic?
A. Servlet

B. JSP

C. Both A and B

D. None of the above

Answer: A. Servlet

174. Which attribute specifies a JSP page that should process any exceptions thrown but not caught in the current page?
A. The ErrorPage Attribute

B. The IsErrorPage Attribute

C. Both A & B

D. None of the above

Answer: A. The ErrorPage Attribute

175. The ASP and JSP technologies are quite similar in the way they support the creation of Dynamic pages, using HTML templates, scripting code and components for business logic.
A. True

B. False

C. none

D. all

Answer: A. True

176. Which of the following is an advantage of the statement – Separation of business logic from JSP ?
A. Custom Tags in JSP

B. JSP Standard Tag Library

C. All the above

D. None of the above

Answer: A. Custom Tags in JSP

177. JSPs eventually are compiled into Java servlets, you can do as much with JSPs as you can do with Java servlets.
A. True

B. False

C. none

D. all

Answer: A. True

178. Java Server Pages often serve the same purpose as programs implemented using the Common Gateway Interface (CGI)
A. True

B. False

C. none

D. all

Answer: A. True

179. Which is the Microsoft solution for providing dynamic Web content?
A. ASP

B. JSP

C. Both A and B

D. None of the above

Answer: A. ASP

180. Which tag is used to execute java source code in JSP?
A. Declaration Tag

B. Scriptlet tag

C. Expression tag

D. None of the above

Answer: B. Scriptlet tag

181. A JSP page consists of which tags?
A. HTML tags

B. JSP tags

C. Both A & B

D. None of the above

Answer: C. Both A & B

182. Which packages does a JSP API consist of?
A. javax.servlet.jsp

B. java.servlet

C. javax.servlet.jsp.tagext

D. Both A & C

Answer: D. Both A & C

183. Which of the scripting of JSP not putting content into service method of the converted servlet?
A. Declarations

B. Scriptlets

C. Expressions

D. None of the above

Answer: C. Expressions

184. The difference between Servlets and JSP is the …………….
A. translation

B. compilation

C. syntax

D. Both A and B

Answer: C. syntax

185. Which of the following are the valid scopes in JSP?
A. request, page, session, application

B. request, page, session, global

C. response, page, session, application

D. request, page, context, application

Answer: A. request, page, session, application

186. JSP includes a mechanism for defining …………………………. or custom tags.
A. static attributes

B. local attributes

C. dynamic attributes

D. global attributes

Answer: C. dynamic attributes

187. Why DB connections are not written directly in JSPs?
A. Response is slow

B. Not a standard J2EE architecture

C. Load Balancing is not possible

D. Both B and C

Answer: D. Both B and C

188. Which is not a directive?
A. include

B. page

C. export

D. taglib

Answer: C. export

189. Which http method send by browser that asks the server to get the page only?
A. get

B. option

C. put

D. post

Answer: A. get

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

Answer: A. Using <%jsp:page> tag

191. _jspService() method of HttpJspPage class should not be overridden.
A. True

B. False

C. none

D. all

Answer: A. True

192. Which is not a directive?
A. include

B. page

C. export

D. useBean

Answer: C. export

193. Attribute used to handle web flow requests.
A. servlet-mapping

B. servlet-attr

C. servlet-flow

D. servlet-requests

Answer: A. servlet-mapping

194. To resolve Facelets views we configure:
A. ViewFacelets

B. ViewResolver

C. View-resolver

D. View_Resolver

Answer: B. ViewResolver

195. File extension of a view state’s name which is by default loaded by facelet page.
A. .xml

B. .hbm.xml

C. .xhtml

D. none of the mentioned

Answer: C. .xhtml

196. Navigation in traditional JSF applications is handled by:
A. linking directly linking to a resource

B. commandLink

C. invoking an action

D. all of the mentioned

Answer: D. all of the mentioned

197. For cross field validation or some sort of barrier to ensure state before you start a flow, we use.
A. FacesContext

B. FaceletContext

C. FacesResolver

D. All of the mentioned

Answer: A. FacesContext

198. Component which additionally provides a pop-up date picker control for its enclosed input field.
A. clientDateValidator

B. clientValidator

C. dateValidator

D. validator

Answer: A. clientDateValidator

199. Component which encloses command button.
A. validateAll

B. validateAllClick

C. validateAllInClick

D. validateAllOnClick

Answer: C. validateAllInClick

Hibernate

200. Which of the following is not a core interface of Hibernate?
A. Configuration

B. Criteria

C. SessionManagement

D. Session

Answer: C. SessionManagement

201. Which of the following is not a core component of Hibernate?
A. JDBC

B. SessionFactory

C. Session

D. Configuration

Answer: A. JDBC

202. Is Session a thread-safe object?
A. True

B. False

C. none

D. all

Answer: B. False

203. Session Factory is a thread-safe object.
A. True

B. False

C. none

D. all

Answer: A. True

204. Which of the following methods returns proxy object?
A. loadDatabase()

B. getDatabase()

C. load()

D. get()

Answer: C. load()

205. Which of the following methods hits database always?
A. load()

B. loadDatabase()

C. getDatabase()

D. get()

Answer: D. get()

206. Which of the following method is used inside session only?
A. merge()

B. update()

C. end()

D. kill()

Answer: B. update()

207. The Session Factory is heavyweight object.
A. False

B. True

C. none

D. all

Answer: B. True

208. Which of the following is not a state of object in Hibernate?
A. Attached()

B. Detached()

C. Persistent()

D. Transient()

Answer: A. Attached()

209. Which of the following is true about HQL?
A. HQL takes java objects in the same way as SQL takes tables.

B. HQL is a Object Oriented Query language

C. HQL is database independent.

D. All of the above.

Answer: D. All of the above.

210. Which of the following is not an inheritance mapping strategies?
A. Table per hierarchy

B. Table per concrete class

C. Table per subclass

D. Table per class

Answer: D. Table per class

211. Which of the following is not an advantage of using Hibernate Query Language?
A. Database independent

B. Easy to write query

C. No need to learn SQL

D. Difficult to implement

Answer: D. Difficult to implement

212. In which file database table configuration is stored?
A. .dbm

B. .hbm

C. .ora

D. .sql

Answer: B. .hbm

213. Which of the following is not an advantage of Hibernate Criteria API?
A. Allows to use aggregate functions

B. Cannot order the result set

C. Allows to fetch only selected columns of result

D. Can add conditions while fetching results

Answer: B. Cannot order the result set

Spring

214. What is the basic concept of Spring?
A. Factory pattern

B. Singleton pattern

C. Dependency injection or Inversion of control

D. Abstract factory pattern

Answer: C. Dependency injection or Inversion of control

215. Which spring module provides the capability of DI or IOC?
A. Spring web

B. Core container

C. AOP

D. Data access

Answer: B. Core container

216. What are beans in the concept of Spring or what are spring beans?
A. Controller classes

B. Service classes

C. Repository

D. Any class that is managed by the container.

Answer: D. Any class that is managed by the container.

217. How does spring achieve DI or IOC?
A. Service locator pattern

B. Factory pattern

C. Abstract factory pattern

D. Singleton pattern

Answer: A. Service locator pattern

218. Which interface in spring is responsible for Instantiating and managing the so called Spring beans?
A. Bean Factory

B. ApplicationContext

C. BeanDefenition

D. BeanDefenition

Answer: B. ApplicationContext

219. Beans can be created by which of the following properties?
A. Scope

B. Property

C. Class

D. It’s own constructor

Answer: D. It’s own constructor

220. Which attribute is used to specify class name of the bean?
A. name

B. id

C. class

D. constructor-args

Answer: C. class

221. Which of the following method can be used to used to instantiate a method?
A. static factory method

B. default-init method

C. destroy method

D. lazy-init method

Answer: A. static factory method

222. Which attribute is used to specify static factory-method?
A. factory-method

B. default-init method

C. destroy method

D. lazy-init method

Answer: A. factory-method

223. Purpose of Static Factory Method?
A. Static method to create an object

B. Initialize bean

C. All of the mentioned

D. None of the mentioned

Answer: A. Static method to create an object

Advanced Java Objective Questions with Answers Pdf Download Online Exam Quiz Test

  • advanced java mcq