Free Essay

Vcctytfggjghyhui

In:

Submitted By navvengunda
Words 532
Pages 3
8)Answer(4) Explanation:It compiles but raise runtime exceptions (java.lang.ArrayIndexOutOfBoundsException)
9.Answer
(2), (4)
Explanation:
This sample code compiles and execute successfully with output 10 but with a warning that "The static method method() from the type ball should be accessed in a static way"
10. Answer
(2)
Explanations
This program execute with printing the output 10 on console.
11. Answer
(2)
Explanations: The abstract keyword must be place before the class Ball because abstract method can only exist in the abstract class not in concrete class.
12. Answer (1)
13. Answer(2)
14. Answer(4)
Explanation:
It has no issue with the code. It will display the output on console.
15. Answer(4)
16. Answer:(2)
Explanation:
It will compile and run successfully there is no issue of using the static method here.
17.
Answer:
(1) or (2)
Explanation:
Place statement (1) or (2) both allow the ClassA method to be called from ClassB
18.
Answer
(2)

19.
Answer :
D is the correct answer.
Thread priorities are set using a positive integer, usually between 1 and 10. t1.setPriority(-3); throws java.lang.IllegalArgumentException. 20.
Answer :
A is the correct answer.
Thread.currentThread().getName() return name of the current thread.

21.
Correct answer is : A

Explanations : You cannot have two methods in the same class with signatures that only differ by return type.

22. "Throwable", the parent class of all exception related classes.
23. throws: Used in a method's signature if a method is capable of causing an exception that it does not handle, so that callers of the method can guard themselves against that exception. If a method is declared as throwing a particular class of exceptions, then any other method that calls it must either have a try-catch clause to handle that exception or must be declared to throw that exception (or its superclass) itself.
24. try{
//lines of code that may throw an exception
}catch(Exception e){
//lines of code to handle the exception thrown in try block
}finally{
//the clean code which is executed always no matter the exception occurs or not.
}

2 try{
}finally{}
3 try{
}catch(Exception e){
//lines of code to handle the exception thrown in try block
}

The catch blocks must always follow the try block. If there are more than one catch blocks they all must follow each other without any block in between. The finally block must follow the catch block if one is present or if the catch block is absent the finally block must follow the try block.
25. Finally block will be executed whether or not an exception is thrown. If an exception is thrown, the finally block will execute even if no catch statement match the exception. Any time a method is about to return to the caller from inside try/catch block, via an uncaught exception or an explicit return statement, the finally block will be executed. Finally is used to free up resources like database connections, IO handles, etc.

26. Answer: The ObjectInputStream class supports the reading of objects from input streams.
27. this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

Similar Documents