User:Shyam123.ckp
Babel user information | ||||
---|---|---|---|---|
| ||||
Users by language |
JAVA Test Yourself (Open your eye and feel the Open Power!!!!!!)
-Shyama(M.Sc(C.A))
1.How do you create a Reader object from an inputstream object?
- use the static createReader() method of the inputstream class.
- use the static createReader() method of the reader class
- create an inputstreamreader object, passing the inputstream object as an argument to the inputstreamreader constructor(*)
- create an outputstreamreader object, passing the inputstream object as an argument to the outputstreamreader constructor.
2.which of the following are true?
- the sleep() method puts a thread in the ready state.
- the yield() method puts a thread in the waiting state.
- the suspend() method is the preferred method for stopping a thread's execution.
- a thread's interrupt() method results in the throwing of the interruptedexception.(*).
3.which of the following classes have a paint() method?
- canvas(*)
- image
- frame(*)
- graphics
4.which of the following is not a wrapper class?
- string(*)
- integer
- boolean
- character
5.public class Test1{
public static void main(String args[]){ System.out.println(method()); } public static int method(){ try{ return 1; } catch(Exception e){ return 2; } finally{ return 3; } }
}
What will be the output?
- 1
- 3
- 2
- 4
6.public class Test2{
public static void main(String args[]){ System.out.println(method()); } public static int method(){ try{ throw new Exception(); return 1; } catch(Exception e){ return 2; } finally{ return 3; } }
}
What will be the output?
- 1
- 2
- 3
- 4
- compiler error
7.public class Test3{
public static void main(String args[]){ System.out.println(method()); } public static int method(){ try{ throw new Exception(); } catch(Exception e){ throw new Exception(); } finally{ return 3; } }
}
What will be the output?
- 3
- 0
- Runtime Exception
- Compile Error
8.public class Test4{
public static void main(String args[]){ System.out.println(method()); } public static int method(){ return; }
}
What will be the output?
- null
- 0
- Compile Error
- Runtime Exception
9.import java.io.IOException;
public class Test5{ public static void main(String args[]){ try{ throw new IOException(); } catch(Exception e){ System.out.println("Excepion"); } catch(IOException e){ System.out.println("IOExcepion"); } }
}
What will be the output?
- Exception
- IOException
- Exception IOException
- Compilers Error
10.public class Test6{
public static void main(String args[]) throws Exception{ try{ throw new Exception(); } finally{ System.out.println("No Error"); } }
}
What will be the output?
- No Error followed by java.lang.Exception
- java.lang.Exception followed by No Error
- No Error
- Compiler Error
11.public class Test7{
public static void main(String args[]) throws Exception{ Test7 t = new Test7(); t.method(); System.out.println("Print"); } public void method()throws Exception{ throw new Exception(); }
}
What will be the output?
- Exception thrown at runtime
- no output
- Compiler Error
12.public class Test8{
public static void main(String args[]) throws Exception{ Test8 t = new Test8(); t.method(); System.out.println("Print"); } public void method(){ try{ throw new Exception(); }catch(Exception e){} }
}
What will be the output?
- Exception thrown at runtime
- no output
- Compiler Error
13.public class Test9 extends A{
public static void main(String args[]) throws Exception{ Test9 t = new Test9(); }
} class A{
A() throws Exception{ System.out.println("A Class"); }
}
What will be the output?
- A Class
- Runtime Exception
- no output
- Compiler Error
14.public class Test10 extends A{
Test10()throws Exception{ System.out.println("Test10 Class"); } public static void main(String args[]) throws Exception{ Test10 t = new Test10(); }
} class A{
A() throws Exception{ System.out.println("A Class"); }
}
What will be the output?
- A Class Test10 Class
- Runtime Exception
- no output
- Compiler Error
15.public class Test11 extends A{
Test11()throws Exception{ System.out.println("Test10 Class"); } Test11(int i){} public static void main(String args[]) throws Exception{ Test11 t = new Test11(); }
} class A{
A() throws Exception{ System.out.println("A Class"); }
}
What will be the output?
- A Class Test10 Class
- Runtime Exception
- no output
- Compiler Error
16.import java.io.IOException;
public class Test12 extends A{ public void method() throws Exception{ System.out.println("Subclass"); } public static void main(String args[]) throws Exception{ A a = new A(); a.method(); a = new Test12(); a.method(); }
} class A{
public void method() throws IOException{ System.out.println("Superclass"); }
}
What will be the output?
- Subclass Superclass
- Runtime Exception
- Superclass Superclass
- Compiler Error
17.What are the legal arguments types for switch?
- int
- byte
- char
- All the above.
18.public class Test16 extends A{
Test16(){ System.out.println("Sub"); } public static void main(String args[]) { Test16 t = new test16(); }
} class A{
A(int i){ System.out.println("Super"); }
}
What will be the output?
- Super Sub
- Super
- Sub
- Compiler Error
19.public class Test17 extends A{
Test17(int i){ System.out.println(i); super(2); } public static void main(String args[]) { Test17 t = new Test17(5); }
} class A{
A(int i){ System.out.println(i); }
}
What will be the output?
- 5 2
- 2 5
- 5 5
- Compiler Error
20.public class Test20 extends A{
Test20(){ this("Hi"); } Test20(String str){ System.out.println(str); } public static void main(String args[]) { Test20 t = new Test20(); }
} class A{
A(){ System.out.println("Super"); }
}
What will be the output?
- Super Hi
- Hi Super
- Super
- Compiler Error