GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

Author Archives: Anonymous

What is the output if ServletA is accessed in the browser? p…

What is the output if ServletA is accessed in the browser? public class ServletA extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { PrintWriter out = res.getWriter(); out.println(“Start of ServletA”); RequestDispatcher rd = req.getRequestDispatcher(“ServletB”); rd.include(req, res); out.println(“End of ServletA”); } } public class ServletB extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { PrintWriter out = res.getWriter(); out.println(“Inside ServletB”); } }

Read Details

What will be the output of the following JSP code snippet? W…

What will be the output of the following JSP code snippet? When the page is refreshed multiple times.

Read Details

Given a bean with a property username, which tag retrieves i…

Given a bean with a property username, which tag retrieves its value in JSP?

Read Details

What will be the output of the following code?  import java….

What will be the output of the following code?  import java.util.Arrays; public class Test { public static void main(String[] args) { int[] arr = {5, 2, 8, 7, 1}; Arrays.sort(arr); System.out.println(Arrays.toString(arr)); } }

Read Details

What will be the output of the following code snippet? class…

What will be the output of the following code snippet? class Animal { void makeSound() { System.out.println(“Animal sound”); } void sleep() { System.out.println(“Animal sleeps”); } } class Dog extends Animal { @Override void makeSound() { System.out.println(“Bark”); } void fetch() { System.out.println(“Dog fetches”); } } public class Main { public static void main(String[] args) { Animal a = new Dog(); a.makeSound(); a.sleep(); } }

Read Details

What does this transaction block do if the second insert fai…

What does this transaction block do if the second insert fails? Connection con = DriverManager.getConnection(url, user, pass); con.setAutoCommit(false); try { Statement stmt = con.createStatement(); stmt.executeUpdate(“INSERT INTO users(name) VALUES (‘John’)”); stmt.executeUpdate(“INSERT INTO users(email) VALUES (‘test@example.com’)”); // Fails con.commit(); } catch (SQLException e) { con.rollback(); System.out.println(“Rolled back”); }

Read Details

Which of the following is used to declare a method or variab…

Which of the following is used to declare a method or variable in JSP?

Read Details

What will happen in the following code?  List

What will happen in the following code?  List

Read Details

What will be the output of the following code?  import java….

What will be the output of the following code?  import java.util.*; public class Test { public static void main(String[] args) { List list = List.copyOf(Arrays.asList(“X”, “Y”, “Z”)); list.add(“W”); } }

Read Details

What is the state of a thread after the start() method is ca…

What is the state of a thread after the start() method is called but before run() begins execution?

Read Details

Posts navigation

Newer posts 1 2 3 4 5 … 52,696 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top