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 java.sql package. Choose the right option.

1. Blob
2. Clob
3. 1 and 2
4. none of the above

4. What is the super class of SQLException? Choose the right option.

1. Exception
2. JDBCException
3. DatabaseException
4. QueryException

5. Which one of the following options is right about the return type of forName() method?

1. Class cls = Class.forName(String);
2. Class.forName(String) returns void
3. Connection con = Class.forName(String);
4. DatabaseConnection dc = Class.forName(String);

6. getMimeType(String) is a method of —————————— interface.
Choose the right option to fill up the blank.

1. ServletConfig
2. ServletContext
3. HttpServlet
4. GenericServlet

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

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

8. Which is the right statement that returns an object of ServletOutputStream?
Choose the right option.

1. ServletOutputStream sos = response.getServletOutputStream ();
2. ServletOutputStream sos = response.getIOStream();
3. ServletOutputStream sos = response.getOutputStream();
4. ServletOutputStream sos = response.getStream();

(where response is an object of HttpServletResponse)

9. Fill up the blank with the return type of getLastModified() method of HttpServlet from the following options.

—————- xyz = getLastModified(HttpServletRequest);

1. long
2. Date
3. Calendar
4. GregorianCalendar

10. What are the two parameters of doDelete() method of HttpServlet. Choose the right option.

public void doDelete(——————–, ———————-)

1. HttpServletRequest, HttpServletResponse
2. ServletConfig, ServletContext
3. ServletConfig, HttpSession
4. none of above

11. Choose the right option to fill the blank.

Session —————————————-.

1. is a conversational state between client and server.
2. consists of multiple requests and responses between client and server.
3. comes with an unique ID
4. all above

12. addCookie(Cookie obj) method returns ————————.
Choose the right option to fill up the blank.

1. void
2. Cookie object (which added)
3. boolean (of true if cookie is added else false)
4. int (0 if added or non-zero if not added)

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

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

1. returns the current HttpSession associated with this request or, if there is no current session returns null.
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, or if no current session, throws exception.
4. none of above

14. Choose the right option to fill up the blank.

setMaxAge(-1) of a cookie indicates ——————————–.

1. Cookie should not be destroyed
2. Cookie to be destroyed when the browser is shutdown
3. throws IllegalArgumentException
4. throws NegativeIndexException

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

Raju&[email protected]

1. Raju%26Reddy%40Hyderabad
2. Raju%40Reddy%26Hyderabad
3. Raju%16Reddy%40Hyderabad
4. Raju%40Reddy%16Hyderabad

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

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

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

17. getParameter(String) belongs to ——————– implicit object.

1. session
2. out
3. request
4. response

18. Which one of the following options is the right syntax for a JSP expression.

1. <%= request.getParameter(“password”); %>
2. <%= request.getParameter(“password”) %>
3. <=% request.getParameter(“password”); %>
4. <% request.getParameter(“password”); %>

19. Which line raises error in the following JSTL code? Choose the right option.

1. <body>
2. <c:set var=”price” scope=”session” value=”${5*3}”/>
3. <c:out value=”{price}”/>
4. </body>

1. 1
2. 2
3. 3
4. 4

20. Choose the right option for the following code if the salary is 80000.


<%!
         public void display(double sal)
         {
                if(sal >= 75000)
	           out.println(" are great");
          }
%>        
<%
          out.println("You");  
          String str2 = request.getParameter("salaryField");
          double salary = Double.parseDouble(str2);
          display(salary);
          out.println(" man");  
%>
  

1. prints You are great man
2. prints You are great
3. prints are great
4. does not print anything as code contains errors

21. Choose the best option that is true.

1. A process can have UID
2. A process can have PID.
3. A process can have PPID.
4. 1, 2, 3

22. Choose the best option that is true.

1. -o is the option of ps command.
2. id is the command to check the UID.
3. 1, 2
4. none above

23. The -T option of ‘who’ indicates ———————————-.

1. when system clock was last changed
2. details of each terminal in a standard format
3. idle time
4. none above

24. Which are the options of ‘ps’ Unix command? Choose the best choice of the following,

1. -ulist
2. -glist, -slist
3. -plist, -tlist
4. 1, 2, 3

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

1. does not remove duplicate (repetitive) lines
2. removes only adjacent duplicate lines in a file by default
3. removes duplicate lines existing anywhere in the file
4. none above

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

echo ‘abc’ | cut -b 1-2

1. the command echoes ab
2. the command echoes c
3. the command echoes abc
4. none above

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

grep [ws] Demo.txt

1. command contains error
2. displays all the lines contains the word ws
3. displays all the lines contains the letters w or s
4. none of above

28. Choose the right option that is true regarding the following two Unix cat and paste commands,

a) cat Demo.txt
b) uniq -s 4 Demo.txt

1. both cat and paste display the same output in the same style
2. cat and paste displays the same output but in a different style
3. paste is of wrong syntax
4. none of above

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

echo ‘hello*’ tr -cd ‘[:alnum:]’

1. echoes hello*
2. echoes hello
3. ehoes nothing
4. none above

30. Choose the option that is FALSE.

1. Number of elements in nested table is unbounded
2. Varray subscript is integer
3. Nested table is always dense and cannot become sparse
4. Varray is only dense

31. Choose the right option that is true.

DECLARE
    TYPE phone IS TABLE OF VARCHAR2(50) INDEX BY VARCHAR2(50);
    telephone_directory phone;
BEGIN
    telephone_directory('home') := '+91 123456789';
    DBMS_output.put_line(telephone_directory.FIRST);
END;  

What is the output of the above associative array code?

1. home
2. +91 123456789
3. 1
4. home = ‘+91 123456789’

32. Choose the right option for the blank that prints all the elements of Varray in a loop.

declare
    type month1 is varray(13) of VARCHAR2(20);
    month2 month1;
    size1 number;
begin
     month2 := month1('Jan','Feb','Mar','Apr','May','Jun','Jul');
     --------------------------------------      -- blank here
 end;  

1. FOR i IN month1.first .. month1.last LOOP dbms_output.put_line(month1(i)); END LOOP;
2. FOR i IN month1.first .. month1.last LOOP dbms_output.put_line(month2(i)); END LOOP;
3. FOR i IN month2.first .. month2.last LOOP dbms_output.put_line(month2(i)); END LOOP;
4. none of above

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;
FORALL i IN type2.FIRST .. type2.LAST
  -----------------------------       -- blank here
COMMIT;	
dbms_output.put_line('Salary update affected');
CLOSE cursor1;
END;  

1. UPDATE Employee SET empsal = empsal+100 WHERE empname = type1(i);
2. UPDATE Employee SET empsal = empsal+100 WHERE empname = type2(i);
3. UPDATE Employee SET empsal = empsal+100 WHERE empname = cursor1(i);
4. none above

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

DECLARE
   TYPE person_address_table IS TABLE OF Person.paddress%TYPE;
   person_address  person_address_table;
BEGIN
   SELECT paddress BULK COLLECT INTO person_address FROM Person;
   FORALL i IN 1 .. person_address.COUNT
       -------------------------------------------------------------------------          -- blank here
   FOR i IN 1  ..  person_address.COUNT
      LOOP  DBMS_OUTPUT.PUT_LINE('Records updated = ' || SQL%BULK_ROWCOUNT(i)); END LOOP;
END;  

1. UPDATE Person SET pname = ‘ION’ WHERE paddress = person_address_table(i);
2. UPDATE Person SET pname = ‘ION’ WHERE paddress = Person.paddress(i);
3. UPDATE Person SET pname = ‘ION’ WHERE paddress = person_address(i);
4. none above

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
            insert into myTable1 values (yourlist(temp));
        exception when others then
            ----------------------------------------------------------------------       -- blank here
    end;  

1. dbms_output.put_line(‘No. Errors: ‘ || sql%bulk_exceptions.count);
2. dbms_output.put_line(‘No. Errors: ‘ || sql%bulk_exceptions.size);
3. dbms_output.put_line(‘No. Errors: ‘ || sql%bulk_exceptions.numsize);
4. dbms_output.put_line(‘No. Errors: ‘ || sql%bulk_exceptions.numcount);

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

1. Classic Query Engine is one of the components of SQL.
2. SQL is not the same for stand-alone LAN systems and internet-based network systems.
3. SQL benefits the application vendors to eliminate the need to develop their own database management software.
4. A select within another select makes a subquery.

37. Which one of the following options adds empaddress column to Employee table in Oracle.

1. alter table Employee add empaddress varchar2(15);
2. alter table Employee add empaddress(varchar2(15));
3. alter table Employee add empaddress: varchar2(15);
4. alter table Employee addto empaddress varchar2(15);

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

select empid, empname, empsal from Employee where empid=null;

1. compiles but prints empid column as null
2. does not compile
3. compiles but displays ‘no rows selected’
4. none above

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

create role manager;
grant alter on Person column person_address to manager;

1. manager gets alter privilege on all the columns of table Person
2. manager gets alter privilege on only column person_address of table Person
3. code does not compile
4. none above

40. Choose the right option that is true about outer join statement.

1. Outer join statement cannot use ‘in’ operator,
2. Outer join uses * (asterisk) on either side (both sides) of ‘where’ clause.
3. Outer join uses + (plus) on either side (both sides) of ‘where’ clause.
4. Outer join is used only to join the columns that do not satisfy any join condition.

SOLUTIONS

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

Leave a Comment

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