Sponsor

Advance Java first year msc(cs) by SoftwareTechIT | java questions and answers mcq

The following quiz “Advance Java MCQ Questions and Answers” provides Multiple Choice Questions (MCQs) related to Advanced Java Programming. These Advanced Java Programming MCQs are also Interviews (campus interview, walk-in interview, company interview), Placement or recruitment, entrance examinations, and competitive examinations oriented. You can practice the below questions to improve your Advanced Java skills. You can click on the View Answer button to check the answer if you needed. Let’s solve this Advance Java MCQ Questions and Answers Quiz. So, Advance Java is also a part of the Java programming language which is generally used for web-based applications and enterprise applications.

01. Which of the following is not a kind of exception that is thrown by the JDBC method?

A.  DataRounding

B.  SQL Exception

C.  DataTruncation

D.  SQL Warning

View Answer

Answer : A
Explanation: None

02. Which of the following option leads to the portability and security of Java?

A.  The applet makes the Java code secure and portable

B.  Bytecode is executed by JVM

C.  Use of exception handling

D.  Dynamic binding between objects

View Answer

Answer : B
Explanation: As we all know, the output of the Java compiler is bytecode, which leads to the security and portability of the Java code. Bytecode is a highly developed set of instructions that are designed to be executed by the Java runtime system known as Java Virtual Machine (JVM). The Java programs executed by the JVM make the code portable and secure. Because JVM prevents the code from generating its side effects. The Java code is portable, as the same byte code can run on any other platform.

 

03. When the ejbRemove method encounters a system problem,it should throw_______

A.  javax.ejb.NoSuchEntityException 

B.  java.ejb.RemoveException 

C.  java.ejb.EJBException 

D.  javax.ejb.DuplicateKeyException 

View Answer

Answer : C
Explanation: java.ejb.EJBException

04. What are the major components of the JDBC?

A.  DriverManager, Statement, and ResultSet

B.  DriverManager, Connection, Statement, and ResultSet

C.  DriverManager, Driver, Connection, and Statement

D.  DriverManager, Driver, Connection, Statement, and ResultSet

View Answer

Answer : D
Explanation: DriverManager, Driver, Connection, Statement, and ResultSet

05. Which of the following is correct about the Statement class of JDBC?

A.  Statement encapsulates an SQL statement which is passed to the database to be planned and executed

B.  Statement encapsulates an SQL statement which is passed to the database to be parsed and compiled

C.  Both of the mentioned

D.  None of the mentioned

View Answer

Answer : C
Explanation: Both of the mentioned

06. Which of the following is advantage of using JDBC connection pool?

A.  Better performance

B.  Slow performance

C.  Using more memory

D.  Using less memory

View Answer

Answer : A
Explanation: Since the JDBC connection takes time to establish. Creating connection at the application start-up and reusing at the time of requirement, helps the performance of the application. Hence, Option A is correct.

07. The method on the result set that tests whether or not there remains at least one unfetched tuple in the result set, is said to be

A.  Fetch method

B.  Next method

C.  Current method

D.  Access method

View Answer

Answer : B
Explanation: Next method

08. To run a compiled java program the machine must have the following loaded and running

A.  Java virtual machine

B.  Java compiler

C.  Java bytecode

D.  A Web browser

View Answer

Answer : A
Explanation: JVM

09. Which is responsible for getting a connection to the database?

A.  Connection

B.  Driver

C.  Statement

D.  ResultSet

View Answer

Answer : B
Explanation: The Driver interface is responsible for getting a connection to the database and the Connection interface is responsible for communication with the database but not making the initial connection. The Statement interface knows how to run the SQL query, and the ResultSet interface knows what was returned by a SELECT query and hence option B is correct.

10. Thin driver is also known as?

A.  Type 3 Driver

B.  Type-2 Driver

C.  Type-4 Driver

D.  Type-1 Driver

View Answer

Answer : C
Explanation: The JDBC thin driver is a pure Java driver and it is also known as Type-4 Driver.

11. How constructor can be used for a servlet?

A.  Initialization and Constructor function

B.  Constructor function

C.  Setup() method

D.  Initialization

View Answer

Answer : A
Explanation: Correct answer is the Initialization and Constructor function as we cannot declare constructors for interface in Java. This means we cannot enforce this requirement to any class which implements the Servlet interface and also, Servlet requires ServletConfig object for initialization which is created by the container.

12. Which package is used for importing swing components?

A.  javax.swing

B.  java.swing

C.  java.awt.

D.  All of the mentioned

View Answer

Answer : A
Explanation: javax.swing is used for importing swing components.

13. Which of the following is/are steps for the servlet life cycle?

A.  Servlet class is loaded

B.  Servlet instance is created

C.  init,Service,destroy method is invoked

D.  All of the mentioned

View Answer

Answer : D
Explanation: All of the above are steps for servlet life cycle.

14. A servlet is a Java program that is invoked via HTTP on the webserver.

A.  True

B.  False

View Answer

Answer : A
Explanation: Yes it is correct that a servlet is a Java program that is invoked via HTTP on the webserver.

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

A.  session.alterAttribute(String name)

B.  session.updateAttribute(String name)

C.  session.getAttribute(String name)

D.  session.setAttribute(String name)

View Answer

Answer : C
Explanation: session.getAttribute(String name) is used to get an attribute in a HTTP Session object in servlets.

16. How can a servlet call a JSP error page?

A.  When the servlet throws the exception, it will automatically be caught by the calling JSP page

B.  This capability is not supported

C.  The servlet needs to forward the request to the specific error page URL. The exception is passed along as an attribute named “javax.servlet.jsp.jspException”

D.  The servlet needs to redirect the response to the specific error page, saving the exception off in a cookie

View Answer

Answer : C
Explanation: The servlet needs to forward the request to the specific error page URL. The exception is passed along as an attribute named “javax.servlet.jsp.jspException” and so option C is correct.

18. __________ is used to read data from a client request.

A.  ServletResponse

B.  ServletRequest

C.  Servlet

D.  ServletConfig

View Answer

Answer : B
Explanation: ServletRequest is used to read data from a client request.

19. Which of the following ways to create a servlet?

A.  Using Servlet Interface

B.  Using GenericServlet class

C.  Using HttpServlet class

D.  All of given

View Answer

Answer : D
Explanation: Different ways to create a servlet are: using Servlet Interface, using GenericServlet class, using HttpServlet class.

20. Which component is used to compile, debug and execute the java program?

A.  JIT

B.  JDK

C.  JVM

D.  JRE

View Answer

Answer : B
Explanation: JDK is a core component of Java Environment and provides all the tools, executables, and binaries required to compile, debug and execute a Java Program so option B is correct.

 

 

Post a Comment

0 Comments