Advanced Java Quiz (Day 15-30)

Last Updated :
Discuss
Comments

Question 1

Which method of a Servlet is called only once?

  • A

    service()

  • B

    doGet()

  • C

    init()

  • D

    destroy()

Question 2

Which of the following is an example of a terminal operation in Java Streams?

  • A

    map()

  • B

    filter()

  • C

    collect()

  • D

    sorted()

Question 3

Which of the following statements about JDBC exception handling is true?

  • A

    ClassNotFoundException occurs when the SQL query syntax is incorrect

  • B

    SQLTimeoutException occurs when a query execution exceeds the defined time limit

  • C

    SQLException is an unchecked exception

  • D

    JDBC resources cannot be closed automatically using try-with-resources

Question 4

What will ${user.name} output in JSP EL?

  • A

    Calls getter method of name property in user bean

  • B

    Directly accesses private field name

  • C

    Prints ${user.name} as plain text

  • D

    Throws compilation error

Question 5

Which JSTL core tag is used for iteration?

  • A

  • B

  • C

  • D

Question 6

Which is the first phase in JSP lifecycle?

  • A

    Compilation

  • B

    Translation

  • C

    Initialization

  • D

    Execution

Question 7

Which advantage does PreparedStatement have over Statement?

  • A

    Easier debugging

  • B

    Faster compilation

  • C

    Precompiled SQL and protection against SQL Injection

  • D

    Returns multiple ResultSets

Question 8

What is the first step to connect Java with a database using JDBC?

  • A

    Create Statement

  • B

    Register JDBC Driver

  • C

    Execute Query

  • D

    Open ResultSet

Question 9

Which method retrieves a session in Servlets?

  • A

    request.getSession()

  • B

    response.getSession()

  • C

    Session.getCurrent()

  • D

    request.createSession()

Question 10

Which statement is correct?

  • A

    doGet sends data in body, doPost in URL

  • B

    doGet is limited in length, doPost supports large data

  • C

    Both are same

  • D

    doPost is idempotent

Tags:

There are 20 questions to complete.

Take a part in the ongoing discussion