hi,
i have listed the following doubts ..... pls answer each one in detail.
(Q-1) Choose the correct one about
thread:
A. The threads from one class ends at the same time.
B. when JVM exists the main method, it will stop only after all the threads are stopped.
C. if there are multiple threads, reading or writing of data of class is inconsitent.
D. programmer has to write a special program for garbagecollection in multiple threads.
My answer is C but thei answer is B & C. My doubt is that even after JVM exits I think there are daemon(system) threads still running.
(Q-2) Whenever I create a frame it does not close by clicking on the "X" on the top right corner of the window. Why is this happening???
(Q-3) What might cause the current thread to stop executing.
A. An InterruptedException is thrown.
B. The thread executes a wait() call.
C. The thread constructs a new Thread.
D. A thread of higher priority becomes ready.
E. The thread executes a waitforID() call on a MediaTracker.
My answer was B, D & E. their answer was A, B, D & E. I think that an InterruptedException is always thrown on a sleeping thread which is not currently executing so how does it stop execution???
(Q-4) Given the following incomplete method.
1. public void method(){
2.
3. if (someTestFails()){
4.
5. }
6.
7.}
You want to make this method throw an IOException if, and only if, the method someTestFails() returns a value of true. Which changes achieve this?
A. Add at line 2: IOException e;
B. Add at line 4: throw e;
C. Add at line 4: throw new IOException();
D. Add at line 6: throw new IOException();
E. Modify the method declaration to indicate that an object of [type] Exception might be thrown.
My answer was C. Their answer was D & E. I have not understood the reason why to throw the exception on line 6 and do we have to compulsarily declare throws clause in the method declaration if we throw an Exception in the method body.
(Q-5)What kind of reader do you use to handle ASCII code?
A. BufferedReader
B. ByteArrayReader
C. PrintWriter
D. InputStreamReader
E. FilterReader
Their answer is D. But why not A & B because they are also readers and all readers always handle ascii code. Pls clarify..i may be wrong.
(Q-6) Does the interpreter stop when the main method stops?
Their answer is NO. Please relate this question to option B of (Q-1).
Please answer these questions in detail...it would be a great help to me.
Sagar