Q 1
-----
public class MyRunner implemenrs Runnable{
int x=5;
public void run(){
this.x=10;
}
public static void main(
String args[]){
MyRunner r=new MyRunner();
new
Thread(r).start();
System.out.println(r.x)
}
}
Ans given : Output can't be determined
But in my openion the output should be 5, bcos after calling the start()
method the call returns to the parent thread. The start() is just to register
the Thread with the Thread Scheduler.
Q 2
-------
public class CloneTest{
public static void main(String args[])
{
int ia[][]={{1,2},null};
int ja[][]=(int[][])ia.clone();
System.out.print((ia==ja)+" ");
System.out.println(ia[0]==ja[0] && ia[1]==ja[1]);
}
}
Object class method
protected Object clone()throws CloneNotSupportedException
I don't understand, why is this compiling........
java.lang.CloneNotSuppertedException extends Exception
this makes it checked exception, checked exceptions must be either caught or
declared by the method in its header (throws clause).