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 ResultSet attribute does not affect the changes made to the database when it is still open.
Choose the right option.

1. ResultSet.TYPE_SCROLL_SENSITIVE
2. ResultSet.TYPE_SCROLL_INSENSITIVE
3. ResultSet.TYPE_FORWARD_ONLY
4. ResultSet.TYPE_FORWARD_BACKWARD

4. The syntax error in SQL statement raises ————————————-.
Choose the right option.

1. InvalidSQLStatementException
2. InvalidSQLException
3. InvalidException
4. SQLException

5. Observe the following snippet of code. Choose the best option.

try
{    		 // think there is a valid Connection object, con, exists
   con.setAutoCommit(false);
   Statement stmt = con.createStatement();
   stmt.executeUpdate("insert into Employee(100, 'S N Rao', 5500.50)");  
   		                            // the above SQL statement is with errors
   con.commit();
}
catch(SQLException e)
{
       ------------------------------		// blank here
 }   

1. con.rollback();
2. con.commit();
3. con.setAutoCommit(false);
4. 1 or 3

6. To write a Servlet which statement is valid.
Choose the right option.

1. implementing Servlet interface
2. extending GenericServlet
3. extending HttpServlet
4. 1, 2, 3

7. When the servlet is not existing to serve the request of the client, what exception is thrown?

1. UnavailableException
2. ServletException
3. ServletUnavailableException
4. None of the above

8. getSessionCookieConfig() is a method of —————- interface.
Choose the right option to fill up the blank.

1. HttpSession
2. ServletContext
3. ServletConfig
4. Cookie

9. Observe the following snippets of code.

a) web.xml snippet:


      $rate
      48
  

b) Servlet snippet:

// here comes servlet that extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{                                                                 
       -----------------------------------------------------------------     // this is the blank to create ctx object
       String s1 = ctx.getInitParameter("$rate");                 // read values from web.xml file
}  

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

1. ServletContext ctx = req.getServletContext();
2. ServletContext ctx = res.getServletContext();
3. ServletContext ctx = out.getServletContext(); // where out is an object of PrintWriter
4. ServletContext ctx = getServletContext();

10. What is the return type of getRemoteAddr() method where req is an object of ServletRequest interface. Fill up the blank with right option.

————— address = req.getRemoteAddr();

1. String
2. URL
3. URLConnection
4. Enumeration

11. What could be the parameter objects of forward() method of RequestDispatcher to compile the code successfully?

1. ServletConfig, ServletContext
2. ServletRequest, ServletResponse
3. HttpServletRequest, HttpServletResponse
4. 2 and 3

12. removeAttribute() method of ServletContext takes a parameter of

1. String object
2. Object object
3. int data type
4. Integer object

13. Choose the right option which is true to fill up the blank.

getLastAccessedTime() method of HttpSession ——————–.

1. returns the last time the client sent a request associated with this session
2. returns the time the client sent the final request associated with this session
3. returns null if no session exists
4. 2 and 3

14. Choose the right option that is true about the following statement.

cookie.setMaxAge(-1);

1. Cookie will be deleted immediately
2. Cookie is not deleted due to negative parameter
3. Cookie will be deleted when the browser is closed
4. It is syntax error giving negative value

15. Choose the right option which is true to fill up the blanks.

Cookie c1 = new Cookie(——– cookieName, ——– cookieValue);

1. Object, int
2. Object, double
3. String, int
4. String, String

16. Choose the correct URL encoding option for the following statement.

rao&[email protected]

1. rao%26raja%40Hyderabad
2. rao%40raja%26Hyderabad
3. rao%20raja%40Hyderabad
4. rao%40raja%40Hyderabad

17. What response is sent to client for the following snippet of JSP code?


Hello 
<% String str = "sir"; %> Wishes

1. Hello in one line and sir and wishes in the next same line
2. Hello, sir, wishes in three different lines
3. Hello and wishes in two different lines
4. No output as errors exist

18. What is the output for the JSP EL division of ${4 / 5} ?

1. 0.8
2. 0
3. No output
4. Syntax error

19. Which of the following options is not the tag of JSTL?

1. HTML tags
2. XML tags
3. Function tags
4. Core tags

20. What is the output of the following JSTL code?

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

${num}
 

1. 2, 4, 6, 8, 10, 12
2. 2, 4, 6, 8, 10
3. 4, 6, 8, 10, 12
4. 4, 6, 8, 10

21. Choose the best option that is true.

1. $kill 31452
2. $kill -9 31452
3. $stop 31452
4. 1, 2

22. Choose the best option that is true.

1. Processes creation can be done using the commands fork and the exec.
2. ‘exec’ replaces the current process with a new one.
3. ‘fork’ creates a copy of the calling process known as child process.
4. 1, 2, 3

23. -e option of ‘ps’ Unix command ———————.

1. displays scheduler data.
2. displays all processes
3. displays a full listing
4. none above

24. Choose one of the following choices of which is NOT the option of ‘whoami’ Unix command?

1. -version
2. -help
3. -log
4. none above

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

1. can be used to cut parts of a line by byte position
2. can be used to cut parts of a line by character position
3. can be used to cut parts of a line by delimiter position
4. 1, 2, 3

26. Choose the best option that is true regarding the following combination of sort and uniq Unix commands.

sort Demo.txt | uniq

1. deletes all the repeated lines that exist randomly
2. deletes all the repeated lines that exist adjacently
3. 1 and 2
4. none above

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

echo “abc def gh ijklm” | tr [:space:] ‘\n’

1. whitespace is converted to a new line
2. tr is not capable to convert space to new line
3. tr command contains error
4. none above

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

fgrep p$ Demo.txt

1. displays all the words that ends with p in file Demo.txt
2. displays all the words that starts with p in file Demo.txt
3. nothing is displayed
4. none above

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

a) echo ‘abcdefgh’ | tr “[:lower:]””[:upper:]”
b) echo ‘abcdefgh’ | tr “a-z””A-Z”

1. a and b give the same output
2. a and b give different output
3. a contains with errors
4. none above

30. Choose the option that is FALSE.

1. Nested table subscript is integer
2. Nested table starts as dense and can become sparse
3. Varray is created in either in PL/SQL block or at schema level
4. Number of elements in an associative array is bounded

31. Choose the best right option that can fill the blank to compile the code successfully.

DECLARE
    TYPE phone IS TABLE OF ------------------- INDEX BY BINARY_INTEGER;
    telephone_directory phone;
BEGIN
    telephone_directory(01) := 123456789;
    DBMS_output.put_line(telephone_directory.COUNT);
END;  

1. PLS_INTEGER, BINARY_INTEGER, INTEGER, NUMBER
2. BINARY_INTEGER, NUMBER
3. INTEGER, NUMBER
4. NUMBER, PLS_INTEGER

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

declare
    type month1 is varray(13) of VARCHAR2(20);
    month2 month1;
begin
     month2 := month1('Jab','Feb','Mar','Apr','May','Jun','Jul');
     dbms_output.put_line('Length before increasing: ' || month2.count);
     ----------------------------------    -- code that increases by one
     dbms_output.put_line('Length after increasing: ' || month2.count);
end;  

1. month2.extend;
2. month2.increase;
3. month2.increase+1;
4. month2.extend+1;

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;
   ------------------------------------         -- blank here
  FORALL i IN type2.FIRST .. type2.LAST
      UPDATE Employee SET empsal = empsal+100 WHERE empname = type2(i);
 COMMIT;	
 dbms_output.put_line('Salary update affected');
 CLOSE cursor1;
 END;  

1. FETCH type1 BULK COLLECT INTO type2 LIMIT 5000;
2. FETCH type2 BULK COLLECT INTO type2 LIMIT 5000;
3. FETCH cursor1 BULK COLLECT INTO type2 LIMIT 5000;
4. none above

34. Choose the right option that fits in the blank that prints the number of exceptions occurred.

declare
          type temp_arr is table of number;
          cust_arr    temp_arr;
          no_exceptions       number;
    begin
           select ccost bulk collect into cust_arr from Customers;
           forall i in cust_arr.first  ..  cust_arr.last save exceptions
                update Customers set ccost = ccost+100 where ccost = cust_arr(i) ;
    exception
        when others then
             no_exceptions := --------------------------------------         -- blank here
         dbms_output.put_line ('No. of exceptions occured: ' || no_exceptions);
end;   

1. sql%bulk_exceptions.length;
2. sql%bulk_exceptions.size;
3. sql%bulk_exceptions.count;
4. sql%bulk_exceptions.length();

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; 
 
        forall temp in 1 .. 50 save exceptions
            -----------------------------------------------------         -- blank here
        exception when others then
            dbms_output.put_line('No. Errors: ' || sql%bulk_exceptions.count);
    end;  

1. insert into myTable1 values (mylist(temp));
2. insert into myTable1 values (yourlist(z));
3. insert into myTable1 values (yourlist(temp));
4. insert into myTable1 values (yourlist(binary_integer));

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

1. SQL provides controlling access to database and database objects.
2. REVOKE does not take back privileges granted from user.
3. The WITH clause breaks the complex queries into simple queries to read and maintain.
4. SQL enhancements support usage of Regular Expression in Built-in SQL Functions.

37. Which one of the following options changes the data type of column empsal of table Employee in Oracle database.

1. MODIFY TABLE Employee ALTER (empsal number(7,2));
2. ALTER TABLE Employee ALTER (empsal number(7,2));
3. ALTER TABLE Employee MODIFY (empsal number(7,2));
4. MODIFY TABLE Employee MODIFY (empsal number(7,2));

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

select empid, empname, empsal, empsal/12 as “Monthly Salary” from Employee;

1. does not compile
2. compiles but raises exception
3. compiles, records are displayed with additional column created as ‘Monthly Salary’.
4. none above

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

create role manager;
grant create session to manager; — Line 1
grant dba to manager; — Line 2
grant create session, dba to manager; — Line 3

1. Line 1, Line 2, Line 3 code compiles successfully
2. Line 1 raises compilation error
3. Line 2 raises compilation error
4. Line 3 raises compilation error

40. Choose the right option that is true about the usage of ‘using’ clause.

1. Used to make ‘non equi join’ statements.
2. Used with many columns having null values.
3. To use when columns have different names with incompatible data types.
4. Used to restrict the number of columns with ‘natural join’ statement.

SOLUTIONS

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

Leave a Comment

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