Set 16 – Advance Java, Oracle, Unix Interview Questions

1. Which one of the following is not a ResultSet attribute? Choose the right option.

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

2. Choose the right option that is true.

1. setAutoCommit(boolean) is a method of Connection interface
2. commit() is a method of Connection interface
3. rollback() is a method of Connection interface
4. 1, 2 and 3

3. What is the checked exception thrown by the static method forName() of class Class?
Choose the right option.

1. IllegalAccessException
2. InstantiationException
3. SecurityException
4. ClassNotFoundException

4. Which one of the following options is NOT JDBC best practice?

1. Use Connection Pool
2. Enable auto commit mode (to true)
3. Use PreparedStatement
4. Use JDBC Batch updates

5. Which one of the following options is the best that compiles successfully.

1. DatabaseMetaData dsmd = con.getMetaData(); // where con is Connection object
2. ResultSetMetaData rsmd = res.getMetaData(); // where res is ResultSet object
3. Blob blob = res.getBlob(3); // where 3 is column index and res is ResultSet object
4. 1, 2 and 3

6. For one Web application how many ServletContext objects are created by the container?
Choose the right option.

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

7. If multiple clients call the same servlet, the container creates ———– of the same servlet as servlet is multithreaded.
Choose the right option to fill up the blank.

1. one init(), one destroy() and multiple service() methods (one for each client)
2. one init(), one destroy() and one service() methods (for all clients)
3. multiple init(),multiple destroy() and multiple service() methods (one for each client)
4. multiple init(), one destroy() and multiple service() methods

8. What is the job of SingleThreadModel interface? Choose right option?

1. To see a the servlet is meant for a single client
2. Servlet does not support single thread model
3. To see the servlet is for multiple clients
4. To see threads should not be created as user threads collide with server threads

9. declareRoles(String roleNames) is a method of ——— interface.
Choose the right option to fill up the blank.

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

10. setSessionTrackingModes() is a method of ——— interface.
Choose the right option to fill up the blank.

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

11. Choose the right option to fill up the blank in the following statement.

Cookie is —————————————————.

1. created on server
2. stored on client
3. a class from javax.servlet.http package
4. all above

12. Which of the following options return an object of RequestDispatcher?
Choose the right option.

1. RequestDispatcher rd = ctx.getRequestDispatcher(“/myBilling”);
// where ctx is an object of ServletContext and myBilling is alias name of other servlet.
2. RequestDispatcher rd = req.getRequestDispatcher(“/myBilling”);
// where req is an object of ServletRequest and myBilling is alias name of other servlet.
3. 1 and 2
4. none of above

13. Choose the right option that is true to fill up the blank in the following statement.

With setMaxAge(int) method we can set the time for ————.

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

14. Fill up the blank by choosing the correct return type.
Choose the right option.

————— xyz = session.getId(); // where session is an object of HttpSession

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

15. If the maximum age for a cookie is not set when the cookie object will be destroyed?
Choose the right option.

1. cookie will never be deleted unless client does
2. cookie will be deleted with a default age of 60 seconds
3. cookie will be deleted with a default age of 3600 seconds
4. when the browser is closed

16. Choose the right URL encoding option for the following statement.
pen, pencil @ amazon.com

1. pen%2C%20pencil%20%40%20amazon.com
2. pen%5C%20pencil%20%40%20amazon.com
3. pen%10C%20pencil%20%40%20amazon.com
4. pen%100C%20pencil%20%40%20amazon.com

17. If “fmt” is the prefix for JSTL formatting tag library, which one of the following is a JSTL tag?
Choose right option.

1. fmt:parseNumber
2. fmt:parseInt
3. fmt:parseFloat
4. fmt:parseByte

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

1. <%@ page info=”project started on 01-07-2019″ import=”java.net.*” %>
<%@ page info=”base Hyderabad” language=”java” %>
2. <%@ page info=”project started on 01-07-2019″ import=”java.net.*” %>
<%@ page session=”false” language=”java” %>
3. <%@ page info=”project starfd on 01-07-2019″ isThreadSafe=”false” %>
<%@ page info=”base Hyderabad” language=”java” %>
4. <%@ page info=”project started on 01-07-2019″ extends=”Demo” %>
<%@ page info=”base Hyderabad” language=”java” %>

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

<body>
<c:forTokens items=”Lux,Rexona,Santoor” delims=”,” var=”item”>
<c:out value=”${item}”/> <p>
</c:forTokens>
</body>

1. Lux Rexona and Santoor in separate lines
2. Lux and Rexona in separate lines
3. Lux Rexona and Santoor in same line
4. no output as errors exist

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

1. request.setAttribute(“userName”, “snrao”) ;
2. application.setAttribute(“userName”, “snrao”) ;
3. session.setAttribute(“userName”, “snrao”) ;
4. 1, 2 and 3

21. Choose the best option that is true.

1. Process wihout a parent process is called orphan process.
2. For an orphan process, the init process may becomes the new PPID.
3. Parent of all processes is init process.
4. 1, 2, 3

22. Choose the best option that is true.

1. This child process inherits all that the parent has in memory with the same pid and ppid.
2. This child process inherits all that the parent has in memory with different pid and ppid.
3. ‘exec’ replaces the current process with a new one.
4. 2 and 3

23. ‘kill -9 1156’ indicates ————-.

1. to kill the process by pid 1156
2. to kill the process by pid -9 1156
3. 1 and 2
4. none above

24. Which is NOT the option of ‘top’ Unix command?

1. -p
2. -l
3. -n
4. -d

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

1. converts uppercase to lowercase or vice versa
2. deletes specific characters or repetitive characters
3. does the jobs of find and replace
4. 1, 2, 3

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

grep -v “hello” /etc/passwd

1. -v informs the grep to invert its output
2. to print all the lines that match the expression hello
3. to print all the lines that do not match the expression hello
4. 1, 3

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

cut -d ” -f2 Demo.txt

1. displays 2nd column of each line in the file Demo.txt
2. displays 2nd line in the file Demo.txt
3. displays 2nd character of each line in the file Demo.txt
4. none above

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

uniq -u Demo.txt

You can skip the duplicate lines and print only unique lines using the -u option

1. displays only one line for a group of duplicate lines
2. displays all the duplicate lines
3. displays only the lines that do not have duplicates
4. none above

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

1. egrep ‘^[l-u] | [L-U]’ Demo.txt
2. egrep ‘^([l-u] | [L-U])’ Demo.txt
3. 1 and 2
4. none above

30. Choose the option that is FALSE.

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

31. Choose the right option for the blank in 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';
  --------------------------------           -- blank here
END;  

Fill up the blank of how to delete the 2nd element of this associative array.

1. emp_name.ELEMENT(02);
2. emp_name.CLEAR(02);
3. emp_name.REMOVE(02);
4. emp_name.DELETE(02);

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

declare
   type namesarray is varray(12) of varchar2(15);
   namesarray1 namesarray;
begin
   namesarray1 := namesarray('hello', 'world');
   dbms_output.put_line(namesarray1(5));
end; 

1. output will be null
2. does not print any output
3. does not compile
4. none of above

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

DECLARE
   TYPE person_info IS RECORD
   (
      pname            Person.pname%TYPE,
      paddress           Person.paddress%TYPE
   );
   TYPE record_info IS TABLE OF person_info;
   name_address  record_info;
BEGIN
    -----------------------------------               -- blank here
    for i in name_address.first .. name_address.last 
    LOOP   dbms_output.put_line(name_address(i).pname || '  ' || name_address(i).paddress);  END LOOP;
END;  

1. SELECT pname, paddress BULK_COLLECT INTO name_address FROM Person;
2. SELECT pname, paddress BULKCOLLECT INTO name_address FROM Person;
3. SELECT pname, paddress BULK COLLECT INTO name_address FROM Person;
4. none above

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

DECLARE
   TYPE my_table IS TABLE OF Person.pname%TYPE;
   your_table  my_table;
BEGIN
   -------------------------------------         -- blank
   FORALL i IN 1 .. your_table.COUNT
       UPDATE Person SET pname = 'TCS' WHERE pname = your_table(i);

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

1. SELECT pname BULK COLLECT INTO my_table FROM Person;
2. SELECT pname BULK COLLECT INTO Person.pname FROM Person;
3. SELECT pname BULK COLLECT INTO your_table FROM Person;
4. none above

35. Choose the right option that fits in the blank to iterate all through the bulk exceptions 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
          INSERT INTO MyTable (char_col) VALUES (v_Strings(v_Count));
   EXCEPTION
     WHEN OTHERS THEN
           DBMS_OUTPUT.PUT_LINE('Got exception: ' || SQLERRM);
           v_NumErrors := ---------------------;          -- blank here
           DBMS_OUTPUT.PUT_LINE('Errors in processing: ' || v_NumErrors);
END;  

1. SQL%BULK_EXCEPTIONS.SIZE
2. SQL%BULK_EXCEPTIONS.COUNT
3. SQL%BULK_EXCEPTIONS.LENGTH
4. SQL%BULK_EXCEPTIONS.NUM_COUNT

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

1. SQL provides removing rights to the structure of database.
2. SQL is not vendor independent and is one of the reasons for its non-popularity.
3. SQL servers as link between front-end and backend systems.
4. Subqueries allow us to use queries within the WHERE clause to do additional filtering.

37. Which one of the following options deletes the records of Employee table in Oracle.

1. truncate table Employee;
2. truncate Employee;
3. delete records Employee;
4. truncate records Employee;

38. Choose the right option for the following select statement on the field empsal of Employee in Oracle.

select empsal, empsal/10, empsal+100 from Employee;

1. the statement does not compile
2. the statement compiles but raises exception
3. the statement compiles fine without errors
4. none of above

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

create role manager;
grant select on Employee column empsal to manager;

1. manager gets the privilege on Employee
2. manager gets the privilege on only column empid of Employee
3. code does not compile
4. none above

40. Choose the right option.

SELECT first_name, de.dept_id, dept_name, empsalary FROM dmart_employees de, dmart_departments dd WHERE de.dept_id=dd.dept_id;

Read the above statement and choose one of the following options that is equivalent to the above one.

1. SELECT first_name, dept_id, empsalary FROM dmart_employees WHERE dept_id IN (SELECT dept_id FROM dmart_departments);
2. SELECT first_name, dept_name, empsalary FROM dmart_employees NATURAL JOIN dmart_departments;
3. SELECT first_name, de.dept_id, dept_name, empsalary FROM dmart_employees de JOIN dmart_departments dd ON de.dept_id = dd.dept_id;
4. SELECT first_name, dept_id, dept_name, empsalary FROM dmart_employees de JOIN dmart_departments dd USING (de.dept_id, dd.dept_id);

SOLUTIONS

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

Leave a Comment

Your email address will not be published.