Set 15 – Advance Java, Oracle, Unix Interview Questions

1. Which of the following statements evaluates to true. Choose the right option.

1. Stored procedure is used for business logic and function is used for calculations.
2. try-catch can be used with stored procedures and not with custom-defined function.
3. Stored procedure does not have a return type and function have.
4. 1, 2 and 3

2. What is the direct super class of CallableStatement? Choose the right option.

1. Statement
2. PreparedStatement
3. PrepareCall
4. Connection

3. Which interface helps us to get the name of the driver used? Choose the right option.

1. Connection
2. ResultSetMetaData
3. DatabaseMetaData
4. MetaData

4. Choose the right option that evaluates to true.

1. execute() method is used to execute both select and update SQL statements
2. executeQuery() method is used to execute only select SQL statements and executeUpdate() is used for only update SQL statements
3. 1 and 2
4. execute() method does not exist.

5. Which one of the following statements executes successfully to set a null value with PreparedStatement without throwing exceptions? Choose the right option.

PreparedStatement psmt = con.prepareStatement(someSqlQuery);
// con is an object of Connection

1. psmt.setNull(3, java.sql.Types.VARCHAR); // 3 is the column index of a table
2. psmt.setNull(3, null);
3. psmt.setString(3, null);
4. psmt.set(3, null);

6. The service() method, when extended with HttpServlet, can have one of the parameters as ————————————–.
Choose the right option to fill up the blank.

1. ServletRequest or HttpServletRequest
2. ServletConfig or HttpServletConfig
3. Response or HttpResponse
4. none above

7. What is the interface used to forward request from one servlet to another?
Choose the right option.

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

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

1. RequestDispatcher rd = request.getRequestDispatcher(“/roses”);
2. RequestDispatcher rd = request.getDispatcher(“/roses”);
3. RequestDispatcher rd = request.createRequestDispatcher(“/roses”);
4. RequestDispatcher rd = request.requestDispatcher(“/roses”);

(where request is an object of HttpServletRequest and roses is the alias name of the other servlet)

9. What is the return type of getParameterNames() method where req is an object of ServletRequest interface. Choose the right option to fill up the blank.

————- names = req. getParameterNames(); // blank here

1. List
2. Set
3. Enumeration
4. String[]

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

protected void doDelete(——————–, ———————-) throws ServletException, IOException

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

11. To which package Cookie class belongs? Choose the right option.

1. javax.servlet
2. javax.servlet.http
3. javax.servlet.session
4. javax.servlet.http.session

12. Which methods return the name and value of a Cookie?
Choose the right option.

1. name() and value()
2. getCookieName() and getCookieValue()
3. cookieName() and cookieValue()
4. getName() and getValue()

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

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

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

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

invalidate() method invalidates the ————————————-.

1. current session of HTTP session
2. current session of Cookie session
3. 1 and 2
4. none of above

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

pen&pencil costs Rs.35

1. pen%26pencil%20costs%20Rs.35
2. pen%20pencil%26costs%26Rs.35
3. pen%22pencil%20costs%20Rs.35
4. pen%20pencil%22costs%22Rs.35

16. Choose the right statement that compiles successfully.

1. Cookie xyz[] = request.getCookies();
2. ArrayList xyz = request.getCookies();
3. HashSet xyz = request.getCookies();
4. Hashtable xyz = request.getCookies();

(where request is an object of HttpServletRequest)

17. If “c” is the prefix for JSTL core tag library, which option will iterate over a list of elements of a Java collection data structure? Choose the right option.

1. <c:iterate>
2. <c:listIterate>
3. <c:forEach>
4. <c:tokens>

18. Choose the right option to include the file contents in a JSP file.

1. <%@ include> directive uses both relative and absolute paths of the file to be included.
2. <jsp:include> action uses only relative path of the file to be included.
3. 1 and 2
4. none of above

19. What is the output of the following snippet of JSTL code.

  
  
 

1. 2, 3 and 4 in separate lines
2. 2 and 3 in separate lines
3. 3
4. no output

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

  
     ---------------------------------------------   	// fill up the blank
     <%@ page import="java.util.*" %>
     <%  Date d=new Date(); %>
     Time Particulars: 

Hours: <%= d.getHours() %>
Minutes: <%= d.getMinutes() %>
Seconds: <%= d.getSeconds() %>

1. <% response.setHeader("refresh", 5); %>
2. <% response.setHeader("5"); %>
3. <% response.setHeader("refresh", "5"); %>
4. <% response.setHeader(5); %>

21. Choose the right option that is true.

1. to terminate the background process use kill command
2. to terminate a background process use Ctrl+C command
3. to terminate a background process use close command
4. to terminate a background process use exit command

22. Choose the best option that is true.

1. ‘fork’ child takes more memory than its parent.
2. ‘exec’ child takes same memory of what parent occupies.
3. 1, 2
4. none above

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

1. -d
2. -m
3. -x
4. -q

24. ‘top’ Unix command can be used to find which process is taking the most resources. We can press the following keys to sort the list. Choose the wrong key.

1. ‘M’ to sort by memory usage
2. ‘P’ to sort by CPU usage
3. ‘N’ to sort by process ID
4. ‘R’ to sort by the running time

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

cat Demo.txt | tr “[:lower:]””[:upper:]”

1. converts lowercase to uppercase letters
2. converts uppercase to lowercase letters
3. 1 and 2
4. command contains errors

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

grep -r “hello” *

1. searches the string hello in the current directory
2. searches the string hello in the current directory and also in its sub-directories
3. command contains error
4. none above

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

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

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

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

cat Demo.txt | sort -k 2

1. sorts all the lines by considering 2nd character
2. sorts all the lines by considering 2nd field
3. skips the 2nd field for comparison
4. none above

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

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

1. searches for hexadecimal digits only
2. searches for octal digits only
3. 1 and 2
4. none above

30. Choose the option that is FALSE.

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

31. Choose the right option for the blank in the following collection associative array 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 total number of elements of this associative array.

1. emp_name.LENGTH()
2. emp_name.LENGTH
3. emp_name.COUNT
4. emp_name.SIZE

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 
   names := student_names('S N Rao', 'Jyothi', 'Jyostna'); 
   total := names.count; 
   ----------------------    -- loop code that prints all the array elements
END;   

1. FOR i in 0 .. total LOOP dbms_output.put_line(names(i)); END LOOP;
2. FOR i in 1 .. total LOOP dbms_output.put_line(names(i)); END LOOP;
3. FOR i in 1 ….. total LOOP dbms_output.put_line(names(i)); END LOOP;
4. none above

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

DECLARE
   TYPE custom1 IS RECORD
   (
      abc                Customers.cname%TYPE,
      def                Customers.ccost%TYPE
   );
   TYPE custom2 IS TABLE OF custom1;
   custom3  custom2;
BEGIN
    SELECT cname, ccost BULK COLLECT INTO custom3 FROM Customers;
    for i in custom3.first .. custom3.last 
    --------------------------------               -- LOOP blank here
END;  

1. LOOP dbms_output.put_line(custom3(i).abc || ‘ ‘ || custom3(i).def); END LOOP;
2. LOOP dbms_output.put_line(custom3[i][1] || ‘ ‘ || custom3[i][2]); END LOOP;
3. LOOP dbms_output.put_line(custom3(i).first || ‘ ‘ || custom3(i).last); END LOOP;
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;
   -------------------------------           -- blank here
       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 = ' || SQL%BULK_ROWCOUNT(i)); END LOOP;
END;   

1. FORALL i IN 1 .. table_demo.COUNT
2. FORALL i IN 1 .. Employee.empsal.COUNT
3. FORALL i IN 1 .. Employee.COUNT
4. FORALL i IN 1 .. table_demo1.COUNT

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

DECLARE
     ------------------------------------   -- blank here
      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 := SQL%BULK_EXCEPTIONS.COUNT;
           DBMS_OUTPUT.PUT_LINE('Errors in processing: ' || v_NumErrors);
END;  

1. TYPE char_col IS TABLE OF MyTable.char_col%TYPE INDEX BY BINARY_INTEGER;
2. TYPE t_Strings IS TABLE OF MyTable.num_col%TYPE INDEX BY BINARY_INTEGER;
3. TYPE num_col IS TABLE OF MyTable.char_col%TYPE INDEX BY BINARY_INTEGER;
4. TYPE t_Strings IS TABLE OF MyTable.char_col%TYPE INDEX BY BINARY_INTEGER;

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

1. SQL guarantees database consistency.
2. SQL allows users to create and drop databases and tables.
3. Filtered aggregations does not allow to aggregate data.
4. SIMPLE_INTEGER of Oracle 11g increases the performance over PLS_INTEGER.

37. Which one of the following options deletes empaddress column from Employee in Oracle.

1. alter table Employee drop empaddress;
2. alter table Employee drop column empaddress;
3. alter table Employee delete column empaddress;
4. modify table Employee drop empaddress;

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

insert into Employee(empid) values(100, ‘TCS’, 4567.89);

1. statement does not compile
2. compiles with exceptions
3. compiles and inserts only 100 in the record
4. none above

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

create role tester;
grant select on Employee to tester;
revoke all on Employee from tester;

1. code does not compile as all privileges are revoked when only select is granted earlier
2. code compiles even when all is revoked when only select is granted earlier
3. code does not compile as it should be ‘all privileges’ instead of ‘all’
4. none above

40. Read the following statement and choose the best option that uses the capabilities of select statement?

select de.dept_id, de.first_name, de.empsalary, dd.dept_name from dmart_employees de, dmart_departments dd where de.dept_id=dd.dept_id;

1. join, projection, selection
2. join, projection, difference
3. join, selection, intersection
4. join, projection, intersection

SOLUTIONS

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

Leave a Comment

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