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 4 driver known as thin driver)

2. Choose the right option that is true.

1. java.util.Date object provides information of date and time
2. java.sql.Date object provides information of date only
3. 1 and 2
4. non of the above

3. To provide batch updates which interface to use? Choose the right option.

1. Statement interface
2. PreparedStatement interface
3. CallableStatement interface
4. 1 and 2

4. Which method is more appropriate for executing SQL statements that are used frequently for client calls?

1. createStatement()
2. prepareStatement()
3. prepareCall()
4. all above

5. Choose the best JDBC practice(s) for JDBC coding?

1. Avoid * (asterisk) and instead write column list for select statement (means, avoid select * from …………………….)
2. Prefer delegate model for connecting database
3. 1 and 2
4. none of the abvoe

6. HttpServlet is ————. Choose the right option to fill up the blank.

1. an abstract class without a single abstract method
2. non-abstract class without any abstract methods
3. interface with all abstract methods
4. none above

7. Fill up the blank with right option where req is an object of HttpServletRequest.

req.setAttribute(“rate”,”2.25″);
————— xyz = req.getAttribute(“rate”);

1. String
2. Double
3. double
4. Object

8. Which class/interface is used to know the Servlet API version the container is supporting?
Choose the right option.

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

9. What is the return type of getAttribute(String key) method where req is an object of ServletRequest interface.

req.setAttribute(“goldrate”, “3547”);
———- xyz = req.getAttribute(“goldrate”);

Choose the right option to fill up the blank.

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

10. addListener(String) is a method of —————- interface.

1. HttpServlet
2. ServletContext
3. ServletContext
4. JspContext

11. What are the parameters of include() and forward() methods of RequestDispatcher used for inter-servlet communication? Note: Order is also important
Choose the right option.

1. ServletRequest, ServletResponse
2. ServletResponse, ServletRequest
3. ServletConfig, ServletContext
4. none of above

12. Calling rd.include(request, response) three times includes the response of other servlet ———— times where rd is an object of RequestDispatcher.
Choose the right option to fill up the blank.

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

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

getAttributeNames() is a method of ——————–.

1. HttpSession
2. ServletContext
3. 1 and 2
4. none of above

14. Which method returns the HTTP session id. Choose right option?
(where session is an object of HttpSession)

1. String id = session.getSessionId();
2. String id = session.getId();
3. String id = session.sessionId();
4. String id = session.getSessionNumber();

15. What is the default value for Cookie class getMaxAge() method if maximum age for a cookie is not set.

int xyz = cookie.getMaxAge(); // where cookie is an object of Cookie
out.println(“Cookie default expiry time ” + xyz + ” seconds”); // where out is an object of PrintWriter

Choose the right option to fill up the blank.

1. 0
2. 1
3. -1
4. null

16. Choose the right statement from the options to create a cookie object

1. Cookie c1 = new Cookie(“rice”, 10);
2. Cookie c1 = new Cookie(“rice”, 10.5);
3 Cookie c1 = new Cookie(“rice”, “10”);
4. Cookie c1 = new Cookie(“rice”, 10.5f);

17. Which implicit object cannot be used from declaration? Choose the right option.

1. application
2. session
3. request
4. config

18. Which of the following is not a JSTL core tag? Choose the right option.

1. <c:out>
2. <c:export>
3. <c:import>
4. <c:remove>

19. What is the output of the following JSTL snippet of code? Choose the right option.

  
   <% int price = 10/0;%>  
  
  
  
   ${myException.message}
  

1. / by zero
2. ArithmeticException: / by zero
3. myException: / bt zero
4. division by zero

20. Which one of the following options is of right JSP syntax to fill up the blank?


<body>
————————– // fill up the blank to include file contents
Sports ends.
</body>

1. <%@ include file="sports.html" %>
2.
3.
4. 1 and 2

21. Choose the best option that is true.

1. Daemons are system-related background processes.
2. A daemon has no controlling terminal.
3. All daemons will have a ? for the tty.
4. 1, 2, 3

22. Choose the best option that is true.

1. Every user process comes with a parent process.
2. Killing of a child process is notified to the parent process with SIGCHLD.
3. It is also possible to get parent process killed even before its child is killed.
4. 1, 2, 3

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

1. the dead processes
2. system login processes
3. the current runlevel.
4. 1, 2, 3

24. Unix command ‘ps -ef’ options indicate ——————————–. Choose the best choice.

1. -e option generates a list of information about every process currently running.
2. -f option generates a list containing fewer items of information for each process than the -l option.
3. 1 and 2
4. none above

25. Which grep command does not recognize meta-characters.
Choose the best option that is true.

1. grep –F
2. fgrep
3. 1 and 2
4. none above

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

grep -n “hello” Demo.txt

1. command contains error
2. displays the count of how many lines exists in the file where hello word exists
3. displays the line numbers along with the text of all the lines in the file where hello word exists
4. none above

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

echo “abc def ghi” | cut -d ” -f6

1. command show error as there is no 6th field to delete
2. command does not show error as simply 6th field is ignored
3. no output is displayed
4. 2 and 3

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

uniq -d Demo.txt

1. displays all lines
2. displays only repeated lines
3. displays one duplicate line per a group of repeated lines
4. none above

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

grep “^[[:alnum:]]” Demo.txt

1. searches a line that starts with any alphabet a-z or A-Z
2. searches a line that starts with any one of all numbers 0 to 9
3. searches a line that starts with any alphabet or any number
4. none above

30. Choose the option that is FALSE.

1. Number of elements in an associative array is unbounded
2. Nested table subscript is integer
3. Associative array can only be dense
4. Varray is created in either in PL/SQL block or at schema level

31. Choose the right option for the blank in the following associative array to compile successfully.

DECLARE
   TYPE marks IS TABLE OF NUMBER INDEX BY VARCHAR2(20);
   student  marks;              
BEGIN
  student('Rao')  := 55;
  student('Yadav')  := 65;
  student('Reddy')  := 75;
  ---------------------------------------------         -- blank here
END;   

Choose the right option that prints Rao.

1. dbms_output.put_line(student.FIRST);
2. dbms_output.put_line(student(‘rao’));
3. dbms_output.put_line(student(student.FIRST));
4. dbms_output.put_line(student(student.FIRST));

32. Choose the right option that is true for the following Varray code.

declare
   type namesarray is varray(2) of varchar2(15);
   namesarray1 namesarray;
begin
   namesarray1(1) := 'hello';
   namesarray1(2) := 'world';
   dbms_output.put_line(namesarray1(1) || '  ' || namesarray1(2));
end;

1. compiles and output is obtained
2. compiles but throws exeception at runtime
3. does not compile
4. none above

33. Choose the right option for the blank that prints all the records of Employee.

DECLARE
   TYPE record_info IS RECORD
   (
      empname       Employee.empname%TYPE,
      empsal            Employee.empsal%TYPE
   );
   TYPE table_info IS TABLE OF record_info;
   all_employees  table_info;
BEGIN
    ---------------------------------------------             -- blank here
    for i in all_employees.first .. all_employees.last loop
    dbms_output.put_line(all_employees(i).empname || '  ' || all_employees(i).empsal);
  end loop;
END;

1. SELECT empname, empsal BULK COLLECT INTO all_employees FROM Employee;
2. SELECT empname, empsal BULKCOLLECT INTO all_employees FROM Employee;
3. SELECT empname, empsal BULK_COLLECT INTO all_employees FROM Employee;
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
   SELECT DISTINCT empsal BULK COLLECT INTO table_demo1 FROM Employee;

   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 = ' || ---------); END LOOP;   
END;

1. SQL%BULK_ROWCOUNT(i)
2. SQL%BULK_ROWCOUNT[i]
3. SQL%BULK_ROWCOUNT
4. none of above

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

DECLARE
     TYPE t_Strings IS TABLE OF MyTable.char_col%TYPE INDEX BY BINARY_INTEGER;
      v_Strings t_Strings;
      v_NumErrors NUMBER;
    BEGIN
      FORALL v_Count IN 1  ..  10
          -------------------------------      -- blank here
   EXCEPTION
     WHEN OTHERS THEN
           DBMS_OUTPUT.PUT_LINE('Got exception: ' || SQLERRM);
           v_NumErrors := SQL%BULK_EXCEPTIONS.COUNT;
           DBMS_OUTPUT.PUT_LINE('Errors in processing: ' || v_NumErrors);
END;

1. INSERT INTO MyTable (char_col) VALUES (v_Strings(v_NumErrors));
2. INSERT INTO MyTable (char_col) VALUES (v_Strings(v_Count));
3. INSERT INTO MyTable (char_col) VALUES (v_Strings(BINARY_INTEGER));
4. INSERT INTO MyTable (char_col) VALUES (v_Strings(t_Strings));

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

1. SQL based database systems are portable across computer systems.
2. SQL is a computer language to manipulate the data stored in a relational database.
3. A select within another select does not make a subquery.
4. SIMPLE_INTEGER of Oracle 11g and PLS_INTEGER do not differ in their numeric overflows.

37. Which one of the following options changes the name of the column empsal of Employee table in Oracle.

1. alter table Employee rename empsal to esal;
2. alter table Employee rename column empsal to esal;
3. alter table Employee modify column empsal to esal;
4. alter table Employee change column empsal to esal;

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

select null, null+10 from Employee;

1. the statement does not compile
2. the statement compiles with exceptions
3. the statement compiles successfully but no records are printed
4. none above

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

create role manager;
create role developer;
grant create table to manager;
grant manager to developer;
revoke create table from manager;

1. after revoking from manager, the developer still having the privilege on create table
2. after revoking from manager, the developer does not have the privilege on create table
3. code is with compilation errors
4. none above

40. When to use FULL OUTER JOIN? Choose the best option from the following.

1. Both tables have null values.
2. You want all incompatible data from one table.
3. You want all compatible data from both tables.
4. You want all incompatible data from both tables.

SOLUTIONS

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

Leave a Comment

Your email address will not be published.