10, మే 2012, గురువారం

SOME OF MY QUIZ QUESTIONS ON APR.2012 WITH ANSWERS


Some of My quiz questions on Apr.2012 with answers
class c
{public static void main(String args[])
{try
{int a=Integer.parseInt(args[0]);
try
{int b=Integer.parseInt(args[1]);
System.out.println(a/b);
}
catch(ArithmeticException ae)
{System.out.println("DIVIDED BY ZERO ERROR");}}
catch(ArrayIndexOutOfBoundsException )
{
aie.printStackTrace();
System.out.println(aie);
System.out.println(" THE CONTROL IS HERE ");
System.out.println("need two parameter");
}}}
Execuation
E:\jit1>java c
java.lang.ArrayIndexOutOfBoundsException: 0
        at c.main(c.java:9)
java.lang.ArrayIndexOutOfBoundsException: 0
 THE CONTROL IS HERE
need two paramenter

public class test1 extends Thread
{
public void run()
{
System.out.println("start");
yield();
resume();
System.out.println("restart");
stop();// you will never resume this thread execution because it will get die this is the end state
//after this method call whatever u write will be left as an unexecuatable code
resume();
System.out.println("not restart");
}
public static void main(String[] jit_it)
{
test1 t=new test1();
t.start();
}
}
Execuation

E:\jit1>javac test1.java
Note: test1.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
E:\jit1>java test1
start
restart

కామెంట్‌లు లేవు:

కామెంట్‌ను పోస్ట్ చేయండి