Java Interview Questions

Jjava Interview Questions

Set 25 – Servlets, JSP, JSTL Interview Questions

1. Choose all the right options that are true about the following servlet. a) web.xml entry snippet for DemoServlet xxxxx DemoServlet trafficfine 3500 b) Servlet code import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class DemoServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String …

Set 25 – Servlets, JSP, JSTL Interview Questions Read More »

Set 24 – Servlets, JSP, JSTL Interview Questions

1. What is the userName value printed if the html input field “user” does not exist. Choose the right option. import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Demo extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String userName = request.getParameter(“user”); out.println(userName); } } 1. null …

Set 24 – Servlets, JSP, JSTL Interview Questions Read More »

Set 23 – Servlets, JSP, JSTL Interview Questions

1. Choose all the right options that are valid URL mappings in web.xml file for the following servlet. public class Servlet1 extends GenericServlet { // business logic goes here } 1. <servlet> <servlet-name>Servlet1</servlet-name> <servlet-class>Servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>Servlet1</servlet-name> <url-pattern>/Servlet1/*</url-pattern> </servlet-mapping> 2. <servlet> <servlet-name>Servlet1</servlet-name> <servlet-class>Servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>Servlet1</servlet-name> <url-pattern>/myServlet1/*</url-pattern> </servlet-mapping> 3. <servlet> <servlet-name>myServlet1</servlet-name> <servlet-class>Servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>myServlet1</servlet-name> …

Set 23 – Servlets, JSP, JSTL Interview Questions Read More »

Set 22 – Servlets, JSP, JSTL Interview Questions

1. a) Read the following servlet import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class DemoServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(“text/html”); response.getWriter().println(“Hello Servlet”); } } What could be right URL mapping in web.xml for the above servlet. Choose the right option. 1. <servlet-mapping> <servlet-name>ds</servlet-name> <url-pattern>/myDemoServlet/*</url-pattern> </servlet-mapping> 2. …

Set 22 – Servlets, JSP, JSTL Interview Questions Read More »

Set 21 – Servlets, JSP, JSTL Interview Questions

1. Choose the right option to fill the blanks to get the values entered by the client as per the following URL. a) URL when client clicks the submit button http://localhost:8080/DemoServlet?t1=Lux&t2=5 b) Servlet snippet import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class DemoServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException …

Set 21 – Servlets, JSP, JSTL Interview Questions Read More »

Set 20 – Advance Java, Oracle, Unix Interview Questions

1. Which option is the best practice for developing JDBC code? Choose the right option. 1. Use java.sql.PreparedStatement for repeated DML commands 2. Use cache of database connections from a connection pool 3. Use column names for accessing ResultSet instead of column index numbers to avoid invalid column index message 4. all above 2. Which …

Set 20 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 19 – Advance Java, Oracle, Unix Interview Questions

1. Choose the best practice for JDBC coding? 1. Close Statement and PreparedStatement objects 2. Select the JDBC driver for the application needs 3. 1 and 2 4. none of above 2. rollback() method is defined —————– interface. Choose the option to fill up the blank. 1. Connection 2. Statement 3. PreparedStatement 4. ResultSet 3. …

Set 19 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 18 – Advance Java, Oracle, Unix Interview Questions

1. Which one of the following Connection interface methods will undo the changes made on database? Choose the right option. 1. public abstract void cancel() throws java.sql.SQLException; 2. public abstract void rollback() throws java.sql.SQLException; 3. public abstract void undo() throws java.sql.SQLException; 4. public abstract void invalidate() throws java.sql.SQLException; 2. commit() method is defined —————– interface. …

Set 18 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 17 – Advance Java, Oracle, Unix Interview Questions

1. Which type of driver converts JDBC calls into database (like Sybase, Oracle etc.) specific calls. Choose the right option. 1. JDBC-ODBC Bridge, plus ODBC driver (Type 1 driver known as bridge driver) 2. Native-API, partly-Java driver (Type 2 driver) 3. JDBC-Net, pure Java driver (Type 3 driver) 4. Native protocol, pure Java driver (Type …

Set 17 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 16 – Advance Java, Oracle, Unix Interview Questions

1. Which one of the following is not a ResultSet attribute? Choose the right option. 1. ResultSet.TYPE_SCROLL_SENSITIVE 2. ResultSet.TYPE_SCROLL_INSENSITIVE 3. ResultSet.TYPE_FORWARD_ONLY 4. ResultSet.TYPE_BACKWARD_ONLY 2. Choose the right option that is true. 1. setAutoCommit(boolean) is a method of Connection interface 2. commit() is a method of Connection interface 3. rollback() is a method of Connection interface …

Set 16 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 15 – Advance Java, Oracle, Unix Interview Questions

1. Which of the following statements evaluates to true. Choose the right option. 1. Stored procedure is used for business logic and function is used for calculations. 2. try-catch can be used with stored procedures and not with custom-defined function. 3. Stored procedure does not have a return type and function have. 4. 1, 2 …

Set 15 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 14 – Advance Java, Oracle, Unix Interview Questions

1. Java Designers divided the JDBC drivers into how many types? Choose the right option. 1. 2 2. 3 3. 4 4. 5 2. Which interface is used to create an object of PreparedStatement interface? Choose the right option. 1. PreparedStatement 2. CallableStatement 3. Statement 4. Connection 3. Which of the following are classes of …

Set 14 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 13 – Advance Java, Oracle, Unix Interview Questions

1. Which of the following options is used for partially compiled SQL queries? Choose the right option. 1. Statement 2. PreparedStatement 3. CallableStatement 4. 2 and 3 2. Which method of ResultSet is used to iterate the records of a table? Choose the right option. 1. hasNext() 2. next() 3. nextRecord() 4. isNext() 3. Which …

Set 13 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 12 – Advance Java, Oracle, Unix Interview Questions

1. Of the four types of JDBC drivers which is the fastest? Choose the right option. 1. Type 1 2. Type 2 3. Type 3 4. Type 4 2. Which type of ResultSet moves the cursor both forward and backward directions. Choose the right option. 1. ResultSet.TYPE_SCROLL_INSENSITIVE 2. ResultSet.TYPE_SCROLL_SENSITIVE 3. ResultSet.TYPE_FORWARD_ONLY 4. 1 and 2 …

Set 12 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 11 – Advance Java, Oracle, Unix Interview Questions

1. JdbcOdbcDriver is ——————–. Choose the right option to fill up the blank. 1. Bridge driver 2. Thin driver 3. Remote driver 4. Native API driver 2. What is the return type of getConnection() method of DriverManager returns? Choose the right option. 1. an object of Connection 2. an object of Statement 3. an object …

Set 11 – Advance Java, Oracle, Unix Interview Questions Read More »

Set 10 – Java, Oracle, Unix Interview Questions

1. What is the return type of remove(Object) method of Collection interface? Choose the right option. 1. boolean 2. Object 3. int 4. Integer 2. What is the output of the following snippet of code? Choose the right option. List numbers1 = new ArrayList(); numbers1.add(2); numbers1.add(1); numbers1.set(1, 2); System.out.println(numbers1); 1. [1, 2] 2. [1, 1] …

Set 10 – Java, Oracle, Unix Interview Questions Read More »

Set 9 – Java, Oracle, Unix Interview Questions

1. The method that writes a string of DataOutputStream is 1. writeLine(String) 2. write(String) 3. writeString(String) 4. writeBytes(String) 2. What about the following snippet of code? Choose the right one that is true. Hashtable ht = new Hashtable(); ht.put(“marks”, 40); ht.put(“marks”, 50); System.out.println(ht.get(“marks”)); 1. prints 40 2. prints 50 3. Compilation error 4. Throws exception …

Set 9 – Java, Oracle, Unix Interview Questions Read More »

Set 8 – Java, Oracle, Unix Interview Questions

1. null key is not accepted by which data structure? 1. HashMap 2. Hashtable 3. List 4. Set 2. What is the output of the following snippet of code? List myList = new ArrayList(); List yourList = new ArrayList(); myList.add(10); myList.add(20); yourList.add(30); yourList.add(40); myList.addAll(yourList); System.out.println(yourList); 1. [10, 20 ] 2. [30, 40 ] 3. [10, …

Set 8 – Java, Oracle, Unix Interview Questions Read More »

Set 7 – Java, Oracle, Unix Interview Questions

1. What is the return type of insertElementAt(Object, int) method of Vector? 1. Object 2. boolean 3. void 4. int 2. Observe the following code snippet and choose the right option. List fruits = new ArrayList(); fruits.add(“mango”); ListIterator li1 = fruits.listIterator(); while(li1.hasNext()) { fruits.add(“apple”); System.out.println(li1.next()); } 1. Compiles and at execution throws ConcurrentModificationException 2. prints …

Set 7 – Java, Oracle, Unix Interview Questions Read More »

Set 6 – Java, Oracle, Unix Interview Questions

1. What is the default capacity and increment rate of Vector? 1. 10 and 10 2. 10 and 11 3. 11 and 11 4. 10 and 5 2. What is the return type of add(Object) method of interface Collection? 1. void 2. boolean 3. Object 4. int 3. Choose more appropriate option. currentThread() method of …

Set 6 – Java, Oracle, Unix Interview Questions Read More »