We have sent an email with your new password.


Java 6 Test

40 Questions  I  By Pearlox
  • Share This on Twitter
  • +
Java Quizzes & Trivia
Pearlox Corp.

Java 6 Test

  
Changes are done, please start the quiz.


Question Excerpt

Removing question excerpt is a premium feature

Upgrade and get a lot more done!
1.  What will happen if you attempt to compile and run the following code?.public class Main {    private int ii;    public static void main(String[] args) {        Main m = new Main();        m.m1();    }    public static void m1() {        System.out.println(ii);    }}
A.
B.
C.
D.
E.
2.  void method() { }Which of the following declares a legal override of this method in a sub class.(Choose all that apply)
A.
B.
C.
D.
E.
3.  Which of the following statements about this code are true?class Testing extends Thread{    public void run(){        for(int i =0; i < 2; i++){            System.out.println(i);        }        }    }public class Sub{    public static void main(String[] args){        Sub m = new Sub();        m.go(new Testing());        }    public void go(Testing t){        t.start();        }    }
A.
B.
C.
D.
E.
4.  Which expression can be used to access the last element of an array. Select the one correct answer
A.
B.
C.
D.
5.  class A extends Thread {private int i;public void run() {i = 1;}public static void main(String[] args) {A a = new A();a.run();System.out.print(a.i);}}
A.
B.
C.
D.
E.
6.  What is the singleton access modifier ?
A.
B.
C.
D.
7.  class C {  public static void main ( String ka [ ] ) {          while ( false ) {                  System.out.println ( "Value" ) ;          }  }}
A.
B.
C.
D.
8.  What is the return type of method round(double d) defined in Math class.........
9.  What is the default priority of a newly created thread
A.
B.
C.
D.
10.  class c1{static{System.out.println("static");}public static void main(String a[]){System.out.println("main");}}
A.
B.
C.
D.
E.
11.  class C{static int f1(int i) {System.out.print(i + ",");return 0;}public static void main (String[] args) {int i = 0;i = i++ + f1(i);System.out.print(i);}}Prints: 0,0Prints: 1,0Prints: 0,1
A.
B.
C.
D.
E.
12.  abstract class C1{public void m1(){        //1}}abstract class C2{ public void m2(){      //2}}
A.
B.
C.
D.
13.  What gets printed when the following code is compiled and run. Select the one correct answer.      public class test {          public static void main(String args[]) {           int i = 1;          do {              i--;          } while (i > 2);          System.out.println(i);          }      }             
A.
B.
C.
D.
14.  Which are valid Java keywords.(Choose all that apply)
A.
B.
C.
D.
E.
15.  Which of these classes defined in java.io and used for file-handling are abstract. Select the two correct answers
A.
B.
C.
D.
E.
16.  What should be done to invoke the run() method on a thread for an object derived from the Thread class. Select the one correct answer.
A.
B.
C.
D.
17.  Consider the codeint[] x = {5,6,7,8,9};int[] y = x;y[2] = 10;What is the value of x[2]?
A.
B.
C.
D.
E.
18.  Which of the following are legal identifier names in Java. Select the two correct answers.
A.
B.
C.
D.
E.
19.  What is the number of bytes used by Java primitive long. Select the one correct answer.
A.
B.
C.
D.
E.
20.  Which of the following statements related to Garbage Collection are correct. Select the two correct answers
A.
B.
C.
D.
21.  interface I {           //1  public class Inner {   ///2                    Inner ( ) {                  System .out . println ( "Inner Created" ) ;          }  };};
A.
B.
C.
D.
22.  Name the collection interface used to represent a sequence of numbers in a fixed order
23.  What all gets printed when the following gets compiled and run. Select the two correct answers.      public class test {          public static void main(String args[]) {               int i=1, j=1;              try {                  i++;                   j--;                  if(i == j)                      i++;              }              catch(ArithmeticException e) {                  System.out.println(0);              }              catch(ArrayIndexOutOfBoundsException e) {                  System.out.println(1);              }              catch(Exception e) {                  System.out.println(2);              }              finally {                  System.out.println(3);              }              System.out.println(4);           }      }             
A.
B.
C.
D.
E.
24.  Which of the following modifiers can be applied to a class that is not a nested class?
A.
B.
C.
D.
25.  Select the one correct answer. Which method defined in Integer class can be used to convert an Integer object to primitive int type.
A.
B.
C.
D.
26.  if(0.0 == -0.0) {  System.out.println("true");}else{    System.out.println("false");}
A.
B.
27.  class C1{public void m1(){    // 1}}class C2 extends C1{ //2private void  m1(){   }}
A.
B.
C.
D.
28.  class bike{}class arr extends bike{public static void main(String[] args) {arr[] a1=new arr[2];    bike[] a2;             a2=a1;                 //3arr[] a3;              a3=a1;                //5}}
A.
B.
C.
D.
E.
29.  Consider the following piece of code:int i;for(i=0; i<10; i++){      /* some code that doesn't modify i */}System.out.println("i="+i); /* line A */What is printed by the statement on line A?
A.
B.
C.
D.
E.
30.  class base{base(){ System.out.println("base");}base(int i1){}}class Super extends base{ Super() {     System.out.println("super");      super(1);      }public static void main(String [] a){      base b1=new  Super();}}
A.
B.
C.
D.
31.  Name the collection interface used to represent collections that maintain unique elements..........
32.  What gets printed when the following program is compiled and run? Select the one correct answer.class test {    static boolean check;    public static void main(String args[]) {        int i;        if(check == true)            i=1;        else            i=2;        if(i=2) i=i+2;        else i = i + 4;        System.out.println(i);     }}
A.
B.
C.
D.
E.
33.  What all gets printed when the following code is compiled and run? Select the three correct answers.      public class xyz {         public static void main(String args[]) {            for(int i = 0; i < 2; i++) {               for(int j = 2; j>= 0; j--) {                  if(i == j) break;                  System.out.println("i=" + i + " j="+j);               }            }         }      }
A.
B.
C.
D.
E.
34.  Which of these statements are true. Select the two correct answers
A.
B.
C.
D.
35.  The number of characters in an object of a class String is given by(Choose the correct answer)
A.
B.
C.
D.
E.
36.  What will be the output if you compile and run the following code ?public class Main {public static void main(String[] args) {  int i1=1; switch(i1){     case 1:              System.out.println("one");     case 2:              System.out.println("two");     case 3:              System.out.println("three");}}}
A.
B.
C.
D.
E.
37.  What is returned when the method substring(2, 4) is invoked on the string "example"? Include the answer in quotes as the result is of type String. .........
38.  class C{public static void main(String[] args) {  try    {        int i1=3/0;      }    catch(Exception e)    {     System.out.println("exception1");     }    catch(NullPointerException e)    {    System.out.println("exception2");        }     finally    {              System.out.println("finally");       }}}
A.
B.
C.
D.
E.
39.  StringBuffer objects once created can not be modified
A.
B.
40.  Which of the following is true. Select the two correct answers
A.
B.
C.
D.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz