Set 2

Set 2


1.
Following snippet of code

1. raises compilation error
2. compiles but throws exception
3. compiles, executes and prints all the elements
4. last element is not printed

2.
Observe, the following snippet of code.

1. All the code is valid and prints hello
2. Does not compile as List declaration is invalid
3. Compiles but throws exception
4. Compiles, executes but no output is printed.

3.
Calling stop() method on the thread

1. The thread from born state can be brought to dead state
2. The thread from runnable state can be brought to dead state
3. The thread from blocked state can be brought to dead state
4. The thread from any state can be brought to dead state

4.
Observe, the following snippet code.

1. The code does not compile as name is not given
2. The code prints main
3. The code prints Thread-0
4. The code prints Thread-1

5.
Observe the code.

1. The above program does not compile as InterruptedException cannot be thrown
2. Compiles but throws exception
3. Compiles, executes and prints hello
4. start() method cannot called like this.

6.
What is the alternative way for try-catch block of event handling?

1. To use throws keyword in the method signature
2. To use throw keyword in the method signature
3. To use either throws or throw in the method signature
4. No alternative way

7.
Java 7 permits to handle multiple exceptions in a single catch statement. Observe, following snippet.

1. Above snippet of code compiles
2. Does not compile
3. Compiles but does not execute
4. Compiles, executes and gives output as the syntax is allowed by Java 7

8.
Observe the snippet of code.

1. The code does not compile as no catch block exists after try block.
2. Compiles but does not execute and thereby no output.
3. Code prints Hello with an exception message.
4. Code prints Hello without any exception message.

9.
What is the immediate super class of IOException?

1. Throwable
2. Exception
3. RuntimeException
4. EOFException

10.
FileOutputStream constructor

1. does not throw FileNotFoundException, as if the destination file does not exist, a new file is created
2. throws FileNotFoundException even if a new file is created when the destination file does not exist
3. As FileOutputStream constructor is overloaded it cannot throw any exceptions
4. Can’t say

11.
Observe, the following snippet of code and choose correct option.

public static void main(String args[])
{

1. try syntax is wrong
2. close() is not used and is not a robust way of programming
3. Stream is closed automatically
4. Code is full of errors

12.
Of the four types of drivers which is the fastest?

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

13.
CallableStatement is used for

1. executing stored procedures
2. executing dynamic SQL statements
3. executing batch updates
4. obtaining metadata of the database

14.
When the permission does not exist to update a table in database, the exception that can handle is

1. InvalidTableException
2. NoPermissionException
3. TableUpdateException
4. SQLException

15.
Using column name instead of column index in ResultSet

1. is one of the best practices of JDBC
2. is not a matter (between column name and column index)
3. raises compilation error
4. raises exception

16.
For one servlet how many ServletConfig objects are created by the container in init() method?

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

17.
By extending GenericServlet to write a servlet

1. service() method can be replaced with doGet() or doPost()
2. service() can be replaced only with doGet()
3. service() can be replaced only with doPost()
4. It is not possible to replace

18.
Observe the following snippet of code.

1. The above code when executed sends response to client “Your name is snrao”.
2. It is a compilation error
3. Compiles but when executed, exceptions are thrown
4. Compiles and executes but response is not sent to client

19.
What is the default age of a cookie if setMaxAge() is not set?

1. 600
2. 1
3. 0
4. -1

20.
Choose the right option of RequestDispatcher..

1. With include(), the client gets the response from servlet1 and with forward(), client() gets the response from servlet2.
2. With include(), the client gets the response of both servlet1 and servlet2 and where as with forward(), client() gets the response of only of servlet2.
3. 1 and 2
4. none of the above is correct.

21.
Which method is best suitable to know if the server has created a session, but the client has not yet joined.

1. isJoin()
2. isJoin(boolean)
3. isNew()
4. isNew(boolean)

22.
The methods of JSP life cycle are

1. _jspInit(), _jspService(), _jspDestroy()
2. jspInit(), jspService(), _jspDestroy()
3. _jspInit(), jspService(), jspDestroy()
4. jspInit(), _ jspService(), jspDestroy()

23.
What you will use for string operations in JSTL?

1. JSTL String
2. JSTL XML
3. JSTL Str
4. JSTL Functions

24.
What is the problem in the following snippet of code?

1. We cannot write a class inside a scriptlet
2. We can write a class inside a declaration only but not in scriptlet
3. We can write a class inside a scriptlet but without public access specifier
4. No problem in the code.

25.
What is the mediator between kernal and the user?

1. hardware
2. shell
3. command libararies
4. none above

26.
In cooperative multitasking

1. one task cannot take the CPU time as long it needs
2. one task may take the CPU time as long it needs
3. CPU time is made into slices
4. one slice is given to one program

27.
In Unix, the dev directory contains

1. user specific files
2. mounted devices specific files
3. device specific files
4. temporary storage specific files

28.
In Unix, shareable files can be accessed by

1. local and remote systems
2. local systems only
3. remote systems only
4. none above

29.
Choose the right option that is true to fit in the blank.

With Predefined exceptions ————————————-.

1. Programmer should raise an exception
2. Oracle raises an exception automatically and should be handled in exception block
3. Exception need not be handled
4. none above

30.
What is the problem in the following Oracle code? Choose the right option that is true.

1. with CREATE OR REPLACE statement, DECLARE should not exist and is a compilation error
2. problem in dbms_output statement
3. ZERO_DIVIDE is undefined
4. no problem in the code and works fine

31.
Choose the right option to fill the blank.

1. storage_error
2. norecords_detected
3. manyrecords_detected
4. none above

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

1. code does not compile as PRAGMA declaration should be the first statement in declaration
2. code does not compile as overdraft and withdraw are assigned in declaration itself and should be in BEGIN block
3. code is without errors, compiles successfully and user gets the message
4. none above

33.
Choose the right option that is true.

1. In Composite type variables, we can delete individual elements from an array.
2. In a collection, the internal components have different data types.
3. You cannot access internal components of composite variables individually.
4. In Composite type variables, an associative array is not persistent.

34.
Choose right option to fill the blank that compiles successfully in Oracle.

1. today date := ’12-DEC-19′;
2. today date := ’12-12-19′;
3. today date := ’12-12-2019′;
4. today date := ‘2-12-19’;

35.
Choose the right option that fits in the blank to compile and execute successfully.

1. WHEN marks = 90 THEN
2. WHEN marks := 90 THEN
3. WHEN 90 THEN
4. none above

36.
Choose the right option for the blank in the following collection code.

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);

37.
Choose the right option that will not compile the following collection record.

1. Line 1 and Line 2
2. Line 3 and Line 4
3. Line 1, Line 2, Line 3 and Line 4
4. code compiles successfully without any errors

38.
Choose the right option that is true regarding SQL cursors.

1. After fetching the cursor, we need not close the cursor.
2. For an explicit cursor, you have control over its execution cycle from OPEN, FETCH, and CLOSE.
3. A cursor cannot be opened in an anonymous block.
4. Explicit cursors automatically created.

39.
Choose the right option that prints all the records in the following cursor code.

1. FETCH persons into pname, paddress;
2. FETCH persons into Person.pname, Person.paddress;
3. FETCH persons into person_name, person_address;
4. none above

40.
What could be the blank to compile the following trigger. Choose right option that is true.

1. for every row
2. for each row
3. for current row
4. none above

SOLUTIONS

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

Leave a Reply

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