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 of ResultSet
4. an object of the driver used to connect the database

3. Which method returns an object of PreparedStatement? Choose the right option.

1. preparedStatement()
2. prepareStatement()
3. preparedCall()
4. prepareCall()

4. Which exception is thrown by Class.forName() method? Choose the right option.

1. SQLException
2. JdbcOdbcException
3. DatabaseConnectionException
4. ClassNotFoundException

5. Which is the best practice for executing different multiple SQL statements on the database with JDBC? Choose the right option.

1. Partially compiled with PreparedStatement
2. Executing stored procedures with CallableStatement
3. addBatch() method of Statement
4. execute() method of Statement

6. Servlet lifecycle methods are —————————–. Choose the right option to fill up the blank.

1. init(), start(), destroy()
2. init(), start(), atop()
3. init(), service(), destroy()
4. start(), doService(), destroy()

7. The parameter of init() method is an object of ————————-.
Choose the right option to fill up the blank.

1. ServletConfig
2. ServletContext
3. initFilter
4. FilterListener

8. What is the return type of getOutputStream()? Choose the right option.

1. OutputStream
2. ServletOutputStream
3. PrintStream
4. ServletStream

9. Observe the following snippet of code. Choose the right option to fill up the blank.

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
 {
        // set content type and PrintWriter object out comes here            
        ---------------------------------------------------------------              // blank here
        while(e.hasMoreElements())
        {
              String name = (String) e.nextElement();
              String value = req.getParameter(name);
              out.println( name + " : " + value +"
"); } }

Choose the right option to create Enumeration object that holds the names of all HTML form fields.

1. Enumeration e = req.getParameterNames();
2. Enumeration e = req.getParameterValues();
3. Enumeration e = req.getParameterNamesAndValues();
4. Enumeration e = req.getParameterFields();

10. What is the return type of setAttribute(String key, Object value) method. Choose the right option.

req.setAttribute(“goldrate”, “3547”); where req is an object of ServletRequest interface.

1. boolean
2. int
3. String
4. void

11. The method getSession() is defined in ———————————.
Choose the right option to fill up the blank.

1. HttpServlet
2. HttpServletRequest
3. HttpSession
4. ServletConfig

12. getRequestDispatcher() method is defined in ———————————.
Choose the right option to fill up the blank.

1. ServletRequest
2. ServletContext
3. ServletRequest and ServletContext
4. RequestDispatcher

13. Choose the right option which is true for the following statement.

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

1. returns the current session associated with this request, or if the request does not have a session, creates one.
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. Read the following statement and choose the right option.

Cookie c1 = new Cookie(“Lux”, 2);

To send Cookie c1 to client and later to retrieve Lux and 2 from cookie, what methods can be used?

1. sendCookie(), getCookieName(), getCookieValue()
2. sendCookie(), getName(), getValue()
3. addCookie(), getCookieName(), getCookieValue()
4. addCookie(), getName(), getValue()

15. What is the return type of Cookie class getMaxAge() method.
Choose the right option to fill up the blank.

——————- xyz = cookie.getMaxAge(). // blank here
out.println(“The cookie will expire by ” + xyz + ” seconds”);

1. int
2. long
3. double
4. Object

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

session.getCreationTime() returns the time in ————————. // blank here
(where session is an object of HttpSession)

1. minutes
2. seconds
3. milliseconds
4. Date object

17. Which JSP lifecycle method cannot be overridden by Developer?

1. init()
2. _init()
3. jspService()
4. _jspService()

18. Read the JSTL code and choose the right option that is true.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>





  

1. compilation error as the syntax of if tag is incorrect.
2. output is false
3. output is Small Man
4. No output

19. Select the right option for the syntax of a scriptlet that prints the value of k.

1. <% int k = 10+5; %>
<%= k; %>
2. <% int k = 10+5;
k; %>
3. <% int k = 10+5; %>
<%= k %>
4. <% int k = 10+5 %>
<% k; %>

20. Observe the following snippet of code? Choose the right option.


<%!
          public void calculate(int x, int y)
          {
              out.println(x*y);
          }
%>
<%
          calculate(10, 20);
%>
 

1. Client gets the response of 200
2. Code has errors and thereby not compiled by container
3. void return type cannot send JSP response to client
4. We cannot pass parameters from scriptlet to declaration without throwing exceptions

21. Choose the option that is FALSE.

1. Each process in the system has a unique pid.
2. The PID number of a closed process can be resued for a new process.
3. Generally, a background process runs without being connected to the keyboard.
4. Use percentage (%) symbol to start a background process.

22. Choose the best option that is true.

1. ‘init’ is a daemon process.
2. By convention, all daemon processes end with the letter ‘d’.
3. 1 and 2
4. none of above

23. Which is NOT the option of ‘ps’ Unix command?

1. -flist
2. -glist
3. -plist
4. -slist

24. Which option of ‘ps’ Unix command displays the process group ID and session ID?

1. -a
2. -c
3. -j
4. -f

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

echo “king kingston” | tr -d ‘k’

1. deletes all k characters from the given string
2. deletes only repetitive characters of k from the given string
3. deletes all characters except k
4. none of above

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

ls -l /etc | grep nag[0-9]

1. displays all the contents of /etc whose name starts with nag followed by any single digit
2. displays all the contents of /etc whose name starts with nag followed by any number of digits
3. displays all the contents of /etc whose name starts with nag followed by multiple times of nag
4. none of above

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

sort -k 2 Demo.txt

1. command contains error
2. does not sort by 2nd field
3. sorts by 2nd field
4. none above

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

cut -c 5-10 Demo.txt

1. extracts characters 5 to 10 from each line in Demo.txt file
2. extracts 5 to 10 lines from Demo.txt file
3. extracts 5th and 10th lines from Demo.txt file
4. none above

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

a) echo ‘abcdefg’ | cut -c 1,6
b) echo ‘abcdefg’ | cut -b 1,6

1. cut commands are of syntax error
2. a and b echoes different outputs
3. a and b echoes the same output
4. none above

30. Choose the right option that is true for the following Varray statements.

1. Number of elements in Varray is bounded
2. Varray subscript can be string or integer
3. Varray is only dense
4. Varray is created in either in PL/SQL block or at schema level

31. Read the following collection code.

DECLARE
   TYPE ename IS TABLE OF VARCHAR2(50) INDEX BY PLS_INTEGER ;
   emp_name ename;
BEGIN
  emp_name('01')  :=  'TCS1, Hyderabad';
  emp_name('02')  :=  'TCS2, Pune';
  emp_name('03')  := 'TCS3, Bubaneswar';
  dbms_output.put_line(---------------------------------);           -- blank here
END;  

Fill up the blank of how to get the last element of this associative array.

1. emp_name.LAST
2. emp_name.3
3. emp_name.(3)
4. emp_name.getLast()

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 
    ------------------------------------------------------------------------            -- blank 
    total := names.count; 
   dbms_output.put_line('Total '|| total || ' Students'); 
END;   

1. student_names := names(‘S N Rao’, ‘Jyothi’, ‘Jyostna’);
2. student_names := student_names(‘S N Rao’, ‘Jyothi’, ‘Jyostna’);
3. names := student_names(‘S N Rao’, ‘Jyothi’, ‘Jyostna’);
4. names := names(‘S N Rao’, ‘Jyothi’, ‘Jyostna’);

33. Choose the right option for the blank 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;
   ---------------------------------------------------------------       -- blank here
  UPDATE Employee SET empsal = empsal-100 WHERE empname = type2(i);
COMMIT;	
dbms_output.put_line('Salary update affected');
CLOSE cursor1;
END;  

1. FORALL i IN type2.FIRST .. type2.LAST
2. FORALL i IN type1.FIRST .. type1.LAST
3. FORALL i IN cursor.FIRST .. cursor1.LAST
4. none above

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

declare
  type bulktab1 is varray(200) of Customers%rowtype;
  bulktab2  bulktab1;
  cursor my_cursor is select cname, ccost from Customers;
begin
  open my_cursor;
  ----------------------------------------------           -- blank here
  close my_cursor;

  for i in bulktab2.first  ..  bulktab2.last  loop
    dbms_output.put_line(bulktab2(i).cname || ',' || bulktab2(i).ccost);
  end loop;
end;  

1. fetch my_cursor bulk collect into bulktab2;
2. fetch my_cursor bulk collect into bulktab1;
3. fetch my_cursor bulk collect into Customers%rowtype;
4. fetch my_cursor bulk collect into my_cursor;

35. Choose the right option that fits in the blank to know the number of exceptions raised.

create table myTable1(z number not null );
declare
    type mylist is table of number index by binary_integer;
    yourlist mylist;
    begin
         yourlist(37) := null;  
         -------------------------------------------------          -- blank here
            insert into myTable1 values (yourlist(temp));
        exception when others then
            dbms_output.put_line('No. Errors: ' || sql%bulk_exceptions.count);
    end;  

1. forall temp in 1 .. 50 throw exceptions
2. forall temp in 1 .. 50 count exceptions
3. forall temp in 1 .. 50 save exceptions
4. forall temp in 1 .. 50 raise exceptions

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

1. Stored procedures are used to implement business logic.
2. SQL databases support stored procedures.
3. SIMPLE_INTEGER of Oracle 11g can never have a NULL value.
4. SQL does not allow users to set permissions on tables, procedures and views.

37. Which one of the following options keeps the records removed from table Employee even after rollback is called, in Oracle.

1. truncate table Employee;
rollback;
2. truncate from Employee;
rollback;
3. delete from Employee;
rollback;
4. remove from Employee;
rollback;

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

select pname, paddress from Person having pname = ‘TCS’;

1. displays all the records with pname as TCS
2. does not display any records
3. does not compile
4. none above

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

create role tester;
grant select on Customer column cust_address to tester;

1. tester gets the select privilege on all the columns of table Customer
2. tester gets the privilege on only column cust_address of table Customer
3. code does not compile
4. none above

40. Choose the best option that is true about the following equijoin of tables?

1. equijoin can join a maximum of two tables or two columns.
2. equijoin condition can be stated in ‘from’ or ‘select’ clauses of select statement
3. equijoin works only when joining columns must be of primary and foreign key columns.
4. It is possible to join num tables, with single column primary keys, by identifying a minimum of num-1 joining conditions.

SOLUTIONS

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

Leave a Comment

Your email address will not be published. Required fields are marked *