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 is printed by the following code fragment?int[] a = {0,1,2,3,4,5,6};System.out.println(a.length);
A.
B.
C.
D.
E.
2.  class c1 extends Exception{}class c2{   static void m1()    {       throw new c1();     }  public static void main(String a[])   {              }}
A.
B.
C.
D.
3.  Which of these statements are true. Select the two correct answers
A.
B.
C.
D.
4.   class C extends Thread{public static void main(String argv[]){          C b = new C();          b.run();  }  public void start(){          for (int i = 0; i <10; i++){                  System.out.println("Value of i = " + i);          }  }}
A.
B.
C.
D.
5.  What will be the output if you compile and run the following code ?public class Main {    public static void main(String[] args) {          char c = 'a';                     switch(c){             case 1:                      System.out.println("one");break;             case 'a':                      System.out.println("two");break;             case 3:                      System.out.println("three");        }    }}
A.
B.
C.
D.
E.
6.  What is the result of evaluating the expression 14 ^ 23. Select the one correct answer
A.
B.
C.
D.
E.
7.  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.
8.  Which declaration of the main method below would allow a class to be started as a standalone program. Select the one correct answer
A.
B.
C.
D.
E.
9.  Is the following statement true or false. The constructor of a class must not have a return type.
A.
B.
10.  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.
11.  You have a requirement to create a class that will store unique object elements. And you do not need to sort these elements.Which interface might be most suitable to meet your requirement?
A.
B.
C.
D.
E.
12.  class C {public static void main(String[] args) {double d1 = Math.floor(0.5);double d2 = Math.floor(1.5);System.out.print(d1 + "," + d2);}}
A.
B.
C.
D.
E.
13.  What is the number of bytes used by Java primitive long. Select the one correct answer.
A.
B.
C.
D.
E.
14.  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.
15.  What gets printed when the following program is compiled and run? Select the one correct answer.class xyz {     public static void main(String args[]) {        int i,j,k;        for (i = 0; i < 3; i++) {            for(j=1; j < 4; j++) {                for(k=2; k<5; k++) {                    if((i == j)   && (j==k))                        System.out.println(i);                }                            }        }    }}
A.
B.
C.
D.
E.
16.  What will be the output if you compile and run the following code ?abstract class Super { abstract void amethod(); static int i;}public class Test extends Super { public static void main(String... args){ int[] arr = new int[5]; for(i=0;i < arr.length;i++) System.out.println(arr[i]); }}
A.
B.
C.
D.
E.
17.  Name the collection interface used to represent a sequence of numbers in a fixed order
18.   Which of the following are true. Select the one correct answers
A.
B.
C.
D.
19.  What is the default priority of a newly created thread
A.
B.
C.
D.
20.  What Locale object represent?
A.
B.
C.
D.
E.
21.   What will happen if you attempt to compile and run the following code?.public class Main {    static int j = 20;    public static void main(String[] args) {        int i = 10;        Main m = new Main();        m.m1(i);        System.out.println(i);        System.out.println(j);    }    public void m1(int x) {        x = x * 2;        j = j * 2;    }}
A.
B.
C.
D.
E.
22.  Considerint a = 6;int b = 12;while(a      System.out.println("In the loop");      a+=2;      b-=2;}How many times is the phrase "In the loop" printed?
A.
B.
C.
D.
E.
23.  What gets printed when the following program is compiled and run? (Choose the correct answer)class Main {    static int i;    public static void main(String... args) {        while (i < 0) {            i--;        }        System.out.println(i);    }}
A.
B.
C.
D.
E.
24.  Which of the following are legal definitions of the main method that can be used to execute a class. Select the one correct answer.
A.
B.
C.
D.
E.
25.  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.
26.  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.
27.  class c1{public static void main(String a[]){c1 ob1=new c1();Object ob2=ob1;System.out.println(ob2 instanceof Object);System.out.println(ob2 instanceof c1);}}
A.
B.
C.
D.
E.
28.   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[]) {           String s1 = "abc";          String s2 = new String("abc");          if(s1 == s2)              System.out.println(1);          else              System.out.println(2);          if(s1.equals(s2))              System.out.println(3);          else              System.out.println(4);          }      }             
A.
B.
C.
D.
29.  At what stage in the following method does the object initially referenced by s becomes available for garbage collection. Select the one correct answer.      void method X()  {           String r = new String("abc");          String s = new String("abc");          r = r+1; //1          r = null; //2          s = s + r; //3      } //4             
A.
B.
C.
D.
E.
30.  System.out.println("String".substring(0,4));This statement will Print
A.
B.
C.
D.
31.  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.
32.  Which of the following is true. Select the two correct answers
A.
B.
C.
D.
33.  Which of these is a legal definition of a method named m assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer.
A.
B.
C.
D.
E.
34.   Which of the following statements are true. Select the two correct answers
A.
B.
C.
D.
35.  class C {  public static void main ( String ka [ ] ) {          while ( false ) {                  System.out.println ( "Value" ) ;          }  }}
A.
B.
C.
D.
36.  StringBuffer objects once created can not be modified
A.
B.
37.  The relationship between a class and its superclass is
A.
B.
C.
38.  What kind of thread is the Garbage collector thread?
A.
B.
C.
D.
E.
39.  All classes of the java.lang package are automatically imported
A.
B.
40.   What happens when the following program is compiled and then the command "java check it out" is executed. Select the one correct answer.class check {    public static void main(String args[]) {        System.out.println(args[args.length-2]);    }}
A.
B.
C.
D.
E.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz