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

3. CallableStatement is used for ————————-. Choose the right option to fill up the blank.

1. executing stored procedures
2. executing dynamic SQL statements
3. executing batch updates
4. obtaining metadata of the database

4. When the permission does not exist to update a table in database, the exception that can handle is —————————-. Choose the right option to fill up the blank.

1. InvalidTableException
2. NoPermissionException
3. TableUpdateException
4. SQLException

5. Using column name instead of column index in ResultSet ———————–.
Choose the right option to fill up the blank.

1. is one of the best practices of JDBC
2. is not a matter (between column name and column index)
3. raises compilation error
4. raises exception

6. For one servlet how many ServletConfig objects are created by the container in init() method?
Choose the right option.

1. 0
2. 1
3. 2
4. cannot be said

7. By extending GenericServlet to write a servlet ——————————————————-.
Choose the right option to fill up the blank.

1. service() method can be replaced with doGet() or doPost()
2. service() can be replaced only with doGet()
3. service() can be replaced only with doPost()
4. service() method cannot be replaced

8. Observe the following snippet of code and choose the right option.

	public void service(HttpServletRequest req, HttpServletResponse res) throws  ServletException, IOException
  { 									                        
       PrintWriter out = res.getWriter();
       ServletConfig config = getServletConfig(); 
       config.setInitParameter("username", "snrao");
       String str = config.getInitParameter("username");	
       out.println("Your user name is " + str);
       out.close();
  }  

1. The above code when executed sends response to client “Your name is snrao”.
2. It is a compilation error
3. Compiles but when executed, exceptions are thrown
4. Compiles and executes but response is not sent to client

9. Observe the following snippets of code.

a) web.xml snippet:


      grate
      1540
  

b) Servlet snippet:

// here comes servlet that extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{                                                                 
       -----------------------------------------------------------------  	//  blank here
       String str1 = config.getInitParameter("grate");      // read values from web.xml file
}  

Choose the right option to fill the blank that returns an object of ServletConig

1. ServletConfig config = req.getServletConfig();
2. ServletConfig config = getServletConfig();
3. ServletConfig config = res.getServletConfig();
4. ServletConfig config = out.getServletConfig(); // out is an object of PrintWriter

10. Choose the right option to fill up the blank in the following servlet snippet.

public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException  
{
     if(---------.equals("172.20.13.5") )     // this is blank
     {
          res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
     }
}  

Which statement returns the client address.

1. res.getRemoteAddr()
2. req.getRemoteAddr()
3. config.getRemoteAddr() // where config is an object of ServletConfig
4. context.getRemoteAddr( ) // where context is an object of ServletContext

11. What is the default age of a cookie if setMaxAge() is not set?

1. 600
2. 1
3. 0
4. -1

12. Choose the right option regarding RequestDispatcher methods.

1. With include(), the client gets the response from servlet1 and with forward(), client() gets the response from servlet2.
2. With include(), the client gets the response of both servlet1 and servlet2 and where as with forward(), client() gets the response of only of servlet2.
3. 1 and 2
4. none of the above is right.

13. Choose the right option regarding the following statement.

HttpSession session = request.getSession(true);
// where request is an object of HttpServletRequest

1. returns the current HttpSession associated with this request or, if there is no current session returns a new session.
2. does not return the current session associated with this request as always creates a new one.
3. returns only the current session associated with this request, as does not create a new one.
4. none of above

14. Which method is best suitable to know if the server has created a session, but the client has not yet joined.

1. isJoin()
2. isJoin(boolean)
3. isNew()
4. isNew(boolean)

15. Choose the right URL encoding option for the following statement.

Rupees 500 equals $7

1. Rupees%20500%20equals%20%247
2. Rupees%24500%24equals%24%207
3. Rupees%28500%28equals%28%247
4. Rupees%22500%22equals%22%247

16. Choose the right option for the return type to fill up the blank.

————– xyz = cookie.getPath(); // where cookie is an object of Cookie

1. String
2. URL
3. Object
4. none above

17. The methods of JSP life cycle are ————————. Choose the right option to fill up the blank.

1. _jspInit(), _jspService(), _jspDestroy()
2. jspInit(), jspService(), _jspDestroy()
3. _jspInit(), jspService(), jspDestroy()
4. jspInit(), _ jspService(), jspDestroy()

18. If “c” is the prefix for JSTL core tag library, what is the output of the following snippet of code?




  

1. does not compile
2. 0
3. 1
4. hello

19. Which one of the following options is of right JSP syntax?

1. <%@ page import=”java.net.*, java.util.Date” %>
2. <%@ page import=”java.net.* java.util.Date;” %>
2. <%@ page import=”java.net., java.util.Date;” %>
4. <%@ page import=”java.net, Date” %>

20. What is the problem in the following snippet of code? Choose the right option.

Demo class is imported here
<%
       public class Test
       {
           int calculate(int x, int y)
           {
              return x+y;
           }
       }
%>  

1. We cannot write a class inside a scriptlet
2. We can write a class inside a declaration only but not in scriptlet
3. We can write a class inside a scriptlet but without public access specifier
4. No problem in the code.

21. Choose the option that is FALSE.

1. We cannot change the PID of a running process.
2. Shell allots the PID number.
3. The maximum value for a PID is 32767 and not 32768, 0 being the scheduler and 1 being the init.
4. The only way to get another PID for the same process is close the earlier process and restart the same process again.

22. Choose the best option that is true.

1. The exit code for a process can be a numeric value between 0 and 255.
2. 0 is considered to be a successful exit code.
3. 1 and 2
4. none of above

23. ‘who’ Unix command with all its options is capable to ——————————-.
Choose the best option possible from the following four options.

1. print active processes spawned by init.
2. print a line of column headings.
3. print IP addresses instead of hostnames.
4. 1, 2, 3

24. Which one of the following commands in combination with ‘ps’ do not exist in Unix.

1. pkill
2. pgrep
3. pps
4. none above

25. Choose the best option that is true regarding the following uniq Unix command.

cat Demo.txt | uniq

1. deletes all the repeated lines in the file Demo.txt
2. deletes all the repeated characters in the file Demo.txt
3. deletes all the repeated pages in the file Demo.txt
4. none above

26. Choose the best option that is true regarding the following grep command.

grep -i HELLO Demo.txt

1. displays all the lines containing HELLO or hello word
2. displays all the lines containing HELLO word
3. grep command contains error
4. none above

27. Choose the best option that is true regarding the following cut Unix command.

cut -c4-7 Demo.txt

1. cut command displays 4 characters
2. cut command displays 3 characters
3. cut command displays 2 characters
4. none above

28. Which of the following commands searches for the lines that ends with letter p in file Demo.txt. Choose the best option that is true.

a) fgrep p$ Demo.txt
b) grep p$ Demo.txt

1. a
2. b
3. a and b
4. none above

29. Which option of egrep is right that compiles successfully.

1. egrep ‘^[h] | [H]’ Demo.txt
2. egrep ‘^h’ | ‘^H’ Demo.txt
3. 1 and 2
4. none above

30. Choose the option that is FALSE.

1. Number of elements in Varray is unbounded
2. Nested table subscript is integer
3. Associative array is created in only in PL/SQL block
4. Nested table starts as dense and can become sparse

31. Choose the right option that fills the blank to compile the following collection associative
Array successfully.

DECLARE
    TYPE house_no IS TABLE OF varchar2(20) INDEX BY pls_integer;
    house_number house_no;
BEGIN    
    ------------------------------        -- blank here
    DBMS_output.put_line(house_number.FIRST);
END;  

1. house_number(‘Mahalaxmi Nilayam’) := 01;
2. house_number := ‘Mahalaxmi Nilayam’;
3. house_number(01) := ‘Mahalaxmi Nilayam’;
4. house_number(01) := 2540;

32. Choose the right option for the blank in the following Varray code that compiles successfully.

DECLARE 
   type student_names IS VARRAY(5) OF VARCHAR2(10); 
   names student_names; 
   total integer; 
BEGIN 
   names := student_names('S N Rao', 'Jyothi', 'Jyostna'); 
   total := ---------------------  ;        		-- returns the size of the array
   dbms_output.put_line('Total '|| total || ' Students'); 
END;  

1. names.size
2. names.length
3. names.count
4. names.length()

33. Choose the right option that updates the salary of all the records of Employee table.

DECLARE
   CURSOR cursor1 IS SELECT empname FROM Employee;
   TYPE type1  IS TABLE OF Employee.empname%TYPE;
   type2  type1;
BEGIN
   OPEN cursor1;
   FETCH cursor1 BULK COLLECT INTO type2 LIMIT 5000;
   FORALL i IN type2.FIRST .. type2.LAST
       UPDATE Employee SET empsal = empsal-100 WHERE empname = type2(i);
       dbms_output.put_line('Updated');
COMMIT;	
CLOSE cursor1;
END;  

1. Updated is printed only ones
2. Updated is printed as many times as records exist
3. does not compile
4. none above

34. Choose the right option that fits in the blank to iterate all through the records of Employee.

DECLARE
   TYPE table_demo IS TABLE OF Employee.empsal%TYPE;
   table_demo1 table_demo;
BEGIN
   -------------------------------------------------------            -- blank here

   FORALL i IN 1 .. table_demo1.COUNT
       UPDATE Employee SET empsal = empsal-100 WHERE empsal = table_demo1(i);

   FOR i IN 1  ..  table_demo1.COUNT
      LOOP  DBMS_OUTPUT.PUT_LINE('Records updated = ' || SQL%BULK_ROWCOUNT(i)); END LOOP;
END;  

1. SELECT DISTINCT empsal BULK COLLECT INTO table_demo FROM Employee;
2. SELECT DISTINCT empsal BULK COLLECT INTO table_demo1 FROM Employee;
3. SELECT DISTINCT Employee.empsal BULK COLLECT INTO table_demo1 FROM Employee;
4. SELECT DISTINCT Employee.empsal BULK COLLECT INTO table_demo FROM Employee;

35. Choose the right option that fits in the blank to iterate all through the records of Employee.

DECLARE
    type table_employee is table of Employee%rowtype;
    table_employee1  table_employee;
    cursor empcursor is select * from Employee;
BEGIN
    OPEN empcursor;
    LOOP 
        FETCH empcursor BULK COLLECT INTO table_employee1 LIMIT 200;
 	EXIT WHEN table_employee1.count = 0;
 	BEGIN 
	     DBMS_OUTPUT.PUT_LINE('Rows affected:  ' || table_employee1.COUNT);
  	     FORALL i IN 1  ..  table_employee1.COUNT
   	         ----------------------------------           -- blank here
                    END;
    END LOOP;
 EXCEPTION
     WHEN OTHERS THEN
           DBMS_OUTPUT.PUT_LINE('Errors in processing: ' || SQL%BULK_EXCEPTIONS.COUNT);
END;  

1. INSERT INTO Employee VALUES table_employee(i);
2. INSERT INTO Employee VALUES table_employee1(i);
3. INSERT INTO Employee VALUES table_employee1[i];
4. INSERT INTO Employee VALUES table_employee1;

36. Choose the right option that evaluates to FALSE from the following.

1. SQL allows users to create and drop databases and tables.
2. SQL is not flexible because it does not allow the structure of database to change dynamically even when users are accessing database contents.
3. SQL is a computer language to manipulate the data stored in a relational database.
4. Oracle database 11g supports SIMPLE_INTEGER data type as subtype of the PLS_INTEGER.

37. Which one of the following options renames the table in Oracle? Choose the right option.

1. rename Employee1 Employee2
2. rename Employee1 to Employee2
3. ren Employee1 Employee2
4. ren Employee1 to Employee2

38. Choose the right option for the following insert statement in Oracle.

insert into Employee(empid, empname, empsal) values(999, ‘Rao’, null);

1. does not compile
2. inserts no value for empsal
3. inserts null value for empsal
4. none above

39. Choose the best option that is true for the following roles and privileges.

create role developer;
grant all on Employee to developer; — Line 1
grant all privileges on Employee to developer; — Line 2

1. Line 1 gets all the privileges to developer
2. Line 2 gets all the privileges to developer
3. 1 and 2
4. none above

40. Choose the best option that is true of the following views.

1. It is possible to create a view as read only.
2. It is possible to create a view as a join on two or more tables.
3. 1 and 2
4. none above

SOLUTIONS

1. 4 2. 4 3. 1 4. 4 5. 1
6. 2 7. 4 8. 2 9. 2 10. 2
11. 4 12. 3 13. 1 14. 3 15. 1
16. 1 17. 4 18. 2 19. 1 20. 3
21. 2 22. 3 23. 4 24. 4 25. 1
26. 1 27. 1 28. 2 29. 1 30. 1
31. 3 32. 3 33. 1 34. 2 35. 2
36. 2 37. 2 38. 2 39. 3 40. 3

Leave a Comment

Your email address will not be published.