I am preapring for the
java certification exam and have few doubts about the questions appeared in khalid's and deepak's mock exams, please help me
KHALID
------
1. which statements concerning the methods notify and notifyAll are true?
A. Instances of class
Thread have a method called notify
B. A call to the method notify will wake the thread that currently owns the monitor of the object
C. The method notify is synchronized
D. The method notifyAll is defined in class Thread
C. When there is more than one thread waiting to obtain the monitor of an object, there no way to be sure which thread will be notified by the notify() method.
2. Under which circumstances will a thread stop
A. the method waitforId() in class mediaTracker is called
B. the run() method that the thread is executing ends
C. The call to the start() method of the Thread object returns
D. The suspend() method is called on the Thread object
E. The wait method is called on the Thread object
3.which is the earliest line in the following code after which the object created line marked (0)will be a candidate for being garbage collected, assuming no compiler
optimizations are done?
public class Q276a9{
static
String f(){
String a="hello";
String b="byte";//(0)
String c=b+"!";//(1)
String d=b;
b=a;//(2)
d=a;//(3)
return c;//(4)
}
public static void main(String args[]){
String msg=f();
System.out.println(msg);//(5)
}
}
A. the line marked (1)
B. the line marked (2)
C. the line marked (3)
D .the line marked (4)
E. the line marked (5)
DEEPAK.HTMLPLANET.COM
---------------------
4.Consider the following class hierarchy and code fragments:
java.lang.Exception
|
java.io.IOException
/ \java.io.StreamcorruptedException java.net.MalformedURLException
try {
URL u = new URL(s); // assume s is defined String
Object o = in.readObject( ); // in is a valid
System.out.println("Success");
}
catch(MalformedURLException e) {
System.out.println("Bad URL");
}
catch( StreamCorruptedException e ) {
System.out.println("Bad file contents");
}
catch(Exception e) {
System.out.println("General Exception");
}
finally {
System.out.println("doing finally part");
}
System.out.println("carrying on");
What lines are output if the method at line 2 throws a MalformedURLException ?
The Answers:
Bad URL
doing finally part
carrying on
My Doubt is about the answer-carrying on, does the program does not terminate after finally.why and when does code after finally is not executed
5 Method names can be re-used anywhere, as long as certain conditions are met:
A. in sub-class with identical arguments and identical return type
B. In same class or sub-class but with same arguments
C. In unrelated classes
D. In same class or sub-class but with different arguments
The Answer: A,C,D,E
Doubt is about the answer- C, whether it is right.
6. What are overloaded methods ?
A. With same argument list and return type
B. with different argument list and same return type
C. overloaded methods can be in different classes
D. Methods with the same name
C. with different arguments list and return type
The Answer is B,C,D,E,F
Doubt is about answer -C, whether it is right.
7.Which of the following are feautres of object oriented language
A. Late binding
B. Overloading
C. Overriding
The answer: A,C
Doubt is whether B is not a feautre OOL
I will be pleased if anyone can help me
Thanks
George