User:Shyam123.ckp

From translatewiki.net
Babel user information
hi-N इस सदस्य को हिन्दी का मातृभाषा के समान ज्ञान है।
en-3 This user has advanced knowledge of English.
This user helps translating MediaWiki.
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?

  1. use the static createReader() method of the inputstream class.
  2. use the static createReader() method of the reader class
  3. create an inputstreamreader object, passing the inputstream object as an argument to the inputstreamreader constructor(*)
  4. create an outputstreamreader object, passing the inputstream object as an argument to the outputstreamreader constructor.

2.which of the following are true?

  1. the sleep() method puts a thread in the ready state.
  2. the yield() method puts a thread in the waiting state.
  3. the suspend() method is the preferred method for stopping a thread's execution.
  4. a thread's interrupt() method results in the throwing of the interruptedexception.(*).

3.which of the following classes have a paint() method?

  1. canvas(*)
  2. image
  3. frame(*)
  4. graphics

4.which of the following is not a wrapper class?

  1. string(*)
  2. integer
  3. boolean
  4. 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. 1
  2. 3
  3. 2
  4. 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. 1
  2. 2
  3. 3
  4. 4
  5. 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?

  1. 3
  2. 0
  3. Runtime Exception
  4. 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?

  1. null
  2. 0
  3. Compile Error
  4. 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?

  1. Exception
  2. IOException
  3. Exception IOException
  4. 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?

  1. No Error followed by java.lang.Exception
  2. java.lang.Exception followed by No Error
  3. No Error
  4. 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?

  1. Print
  2. Exception thrown at runtime
  3. no output
  4. 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?

  1. Print
  2. Exception thrown at runtime
  3. no output
  4. 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?

  1. A Class
  2. Runtime Exception
  3. no output
  4. 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?

  1. A Class Test10 Class
  2. Runtime Exception
  3. no output
  4. 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?

  1. A Class Test10 Class
  2. Runtime Exception
  3. no output
  4. 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?

  1. Subclass Superclass
  2. Runtime Exception
  3. Superclass Superclass
  4. Compiler Error

17.What are the legal arguments types for switch?

  1. int
  2. byte
  3. char
  4. 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?

  1. Super Sub
  2. Super
  3. Sub
  4. 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?

  1. 5 2
  2. 2 5
  3. 5 5
  4. 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?

  1. Super Hi
  2. Hi Super
  3. Super
  4. Compiler Error