1. Which interface is not in the Collection hierarchy?
1. List
2. Set
3. Map
4. Queue
2. What is the output of the following snippet of code?
Hashtable ht = new Hashtable();
StringBuffer sb1 = new StringBuffer("hello");
ht.put(sb1, "sir");
Enumeration e = ht.keys();
while(e.hasMoreElements())
{
Object obj1 = e.nextElement();
Object obj2 = ht.get(obj1);
System.out.println(obj1 + ":" + obj2);
}
1. Does not compile
2. Does not execute
3. sb1:sir
4. hello:sir
3. isAlive() method returns true when the thread is in
1. born state
2. runnable state
3. blocked state
4. 2 and 3
4. Which one of the following methods is capable to throw IllegalArgumentException or IllegalMonitorStateException or InterruptedException.
1. wait()
2. notify()
3. isAlive()
4. join()
5. What is the output when the following program is executed?
public class Demo extends Thread
{
public void run()
{
System.out.println("From run(): " + this.isAlive());
}
public static void main(String args[])
{
Demo d1 =new Demo();
System.out.println("From main(): " + d1.isAlive());
d1.start();
}
}
1. From main(): false and From run(): false
2. From main(): true and From run(): false
3. From main(): false and From run(): true
4. From main(): true and From run(): true
6. Subclasses of RuntimeException are known as
1. Checked exception
2. Unchecked exception
3. It is not an exception
4. None of the above
7. What is the output of the following snippet of code?
public static void main(String args[])
{
try
{
int a[] = { 0, 1, 2 }, b = 0;
int c = a[3] / b;
}
catch(ArithmeticException e) { System.err.println("Hello 1"); }
catch(ArrayIndexOutOfBoundsException e) { System.err.println("Hello 2"); }
}
1. Hello 1
2. Hello 2
3. Does not compile
4. Compiles but at execution time gives system defined message.
8. What is the output of the following program?
public class Demo
{
public static void main(String args[])
{
try
{
System.out.println(10/0);
}
catch(InterruptedException e) { System.out.println("Hello 1"); }
catch(Exception e) { System.out.println("Hello 2"); }
}
}
1. Hello 1
2. Hello 2
3. Compiles, executes and does not give any output
4. Does not compile
9. Super class of IOException is
1. Exception
2. FileNotFoundException
3. EOFException
4. UnavailableException
10. DataInput interface is implemented directly by
1. DataInputStream
2. RandomAccessFile
3. ObjectInputStream
4. 1 and 2
11. Which one of the following statements is not correct to open a file.
1 BufferedReader br = new BufferedReader(new FileReader(“abc.txt”));
2. BufferedInputStream bis = new BufferedInputStream (new FileInputStream (“abc.txt”));
3. RandomAccessFile raf= new RandomAccessFile(“abc.txt”);
4. File f1 = new File(“abc.txt”);
12. Which of the following options is used for partially compiled SQL queries?
1. Statement
2. PreparedStatement
3. CallableStatement
4. 2 and 3
13. Which ResultSet attribute does not affect the changes made to the database when it is still open.
1. ResultSet.TYPE_SCROLL_SENSITIVE
2. ResultSet.TYPE_SCROLL_INSENSITIVE
3. ResultSet.TYPE_FORWARD_ONLY
4. ResultSet.TYPE_FORWARD_BACKWARD
14. The syntax error in SQL statement raises
1. InvalidSQLStatementException
2. InvalidSQLException
3. InvalidException
4. SQLException
15. Observe the following snippet of code. Choose the right option to fill the blank.
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)
{
------------------------ // here, which is the better statement to write
}
1. con.rollback();
2. con.commit();
3. con.setAutoCommit(false);
4. 1 or 3
16. To write a Servlet which statement is valid.
1. implementing Servlet interface
2. extending GenericServlet
3. extending HttpServlet
4. 1 or 2 or 3
17. 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
18.
HTML snippet of code
Servlet snippet of code
public void doPost(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
String str1 = req.getParameter("add" );
String str2 = req.getParameter("list");
}
When the user clicks “Add Cookie” button, what will be the value of str2 ?
1. List Cookies
2. Add Cookie
3. null
4. Empty string value
19. What are the parameter objects (including sequence) of forward() method of RequestDispatcher?
1. ServletConfig, ServletContext
2. HttpServletRequest, HttpServletResponse
3. HttpServletResponse, HttpServletRequest
4. ServletContext, ServletConfig
20. removeAttribute() method of ServletContext takes a parameter of
1. String object
2. Object object
3. int data type
4. Integer object
21. 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
22. 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
23. What is the output for the JSP EL division of ${4 / 5} ?
1. 0.8
2. 0
3. No output
4. Syntax error
24. 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
25. Which interacts directly with the operating system hardware?
1. shell
2. kernal
3. application libraries
4. application layer
26. In cooperative multitasking
1. CPU time is given to another task when current task job is over
2. CPU time is held by the current task thinking it may require some more time and do not relinquish to another task immediately
3. CPU time is made into slices
4. one slice is given to one program
27. In Unix, the etc directory contains
1. user specific files
2. mounted devices specific files
3. device specific files
4. system configuration files
28. Static files such as binaries can be altered by
1. user only
2. administrator only
3. 1 or 2
4. none above
29. An exception block handles ——————————.
1. runtime error
2. compile time error
3. syntax error
4. 1 or 2
30. What is the appropriate statement for the blank in the following Oracle code with respect to input values for the procedure? Choose the right option.
CREATE OR REPLACE PROCEDURE calculate(x IN NUMBER, y IN NUMBER)
IS
z NUMBER;
begin
z := x/y;
dbms_output.put_line('Value is ' || z);
EXCEPTION
WHEN ---------------------------- THEN -- blank here
dbms_output.put_line('Hello 1');
END;
1. VALUE_ERROR
2. ZERO_DIVIDE
3. PROGRAM_ERROR
4. INVALID_NUMBER
31. Choose the right option that is true.
create or replace procedure PragmaDemo(id in number)
IS
manyrecords_detected EXCEPTION;
manyrecords_detected EXCEPTION;
salary number;
PRAGMA EXCEPTION_INIT(manyrecords_detected, -1422);
z number;
BEGIN
select empsal into salary from Employee where empid=id;
dbms_output.put_line('Salary of ' || id || ' is ' || salary);
EXCEPTION
WHEN manyrecords_detected THEN
dbms_output.put_line('Many records exist on this ID');
END;
1. manyrecords_detected is declared twice and is an error
2. manyrecords_detected is declared twice and is not an error
3. compiler takes care and compiles successfully
4. compiler does not take care and compiles successfully
32. What could be the blank for the Pragma to compile successfully? Choose the right option.
DECLARE
age_exception EXCEPTION;
visitor_age NUMBER := 9;
PRAGMA EXCEPTION_INIT(age_exception, -1000);
BEGIN
IF visitor_age < 10 THEN
RAISE age_exception;
END IF;
DBMS_OUTPUT.PUT_LINE('Enjoy water games');
EXCEPTION
WHEN -------------------------- THEN -- blank
DBMS_OUTPUT.PUT_LINE('Not permitted for water games. Go for other');
END;
1. all
2. age_exception
3. all_others
4. remaining
33. Choose the right option that is true.
1. In Composite type variables, arrays may have non-consecutive subscripts.
2. In Composite type variables, each key of an associative array should be unique.
3. You cannot pass entire composite variables to subprograms as parameters.
4. In Composite type variables, an associative array is stored on disk.
34. Which lines of the following code compile successfully, Choose the best right option.
DECLARE
summer boolean := true; -- Line 1
winter boolean := false; -- Line 2
spring boolean := null; -- Line 3
BEGIN
dbms_output.put_line('hello');
END;
1. Line 1, Line 2, Line 3
2. Line 1, Line 2
3. Line 3
4. none above
35. Choose the right option that is true.
DECLARE
marks number(3);
BEGIN
WHEN marks >= 90 THEN
dbms_output.put_line('Excellent');
ELSE
dbms_output.put_line('Improve');
END;
1. code compiles and gives output Excellent
2. code compiles and gives output Improve
3. code does not compile
4. none above
36. 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
37. Choose the right option that is true for the following nested record.
DECLARE
TYPE marks IS RECORD (
maths pls_integer,
physics binary_integer
);
TYPE student IS RECORD(
address varchar2(20),
subject_marks marks
);
std1 student;
BEGIN
std1.address := 'Hyderabd';
std1.subject_marks.maths := 50;
std1.subject_marks.physics := 60;
dbms_output.put_line('Avg: ' || (std1.subject_marks.maths+std1.subject_marks.physics)/2);
END;
1. Code compiles successfully and output is displayed
2. Code compiles successfully but output is not displayed
3. Error in code
4. Does not compile
38. Choose the right option that is true regarding SQL cursors.
1. Implicit cursor will not work with SELECT INTO ..... statement.
2. A cursor variable can be passed as a parameter.
3. An explicit cursor is a SELECT statement that need not be declared explicitly in the declaration section.
4. The FETCH statement places the contents of all the rows at a time.
39. Choose the right option that prints all the records in the following cursor code.
BEGIN
FOR emp IN(SELECT empid, empname from Employee)
LOOP
DBMS_OUTPUT.PUT_LINE(--------------------------------------------); -- blank here
END LOOP;
END;
1. Employee.empid || ', ' || Employee.empname
2. empid || ', ' || empname
3. emp.empid || ', ' || emp.empname
4. none above
40. Choose the best right option for the blank, that compiles successfully, in the following user-defined function.
CREATE OR REPLACE FUNCTION get_id(salary number)
RETURN number
-------------------- -- blank here
eid number;
BEGIN
SELECT empid INTO eid FROM Employee WHERE empsal = 1101;
RETURN(eid);
END;
1. IS
2. AS
3. IS or AS
4. none above
SOLUTIONS
1. 3 | 2. 4 | 3. 4 | 4. 1 | 5. 3 |
6. 2 | 7. 2 | 8. 4 | 9. 1 | 10. 4 |
11. 3 | 12. 2 | 13. 2 | 14. 4 | 15. 1 |
16. 4 | 17. 1 | 18. 3 | 19. 2 | 20. 1 |
21. 3 | 22. 3 | 23. 4 | 24. 1 | 25. 2 |
26. 1 | 27. 4 | 28. 2 | 29. 1 | 30. 2 |
31. 1 | 32. 2 | 33. 2 | 34. 1 | 35. 3 |
36. 3 | 37. 1 | 38. 2 | 39. 3 | 40. 3 |