We have sent an email with your new password.


Java 6 Test

40 Questions  I  By Pearlox
Java 6 Test
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 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.
2.  System.out.println("String".substring(0,4));This statement will Print
A.
B.
C.
D.
3.  Which method defined in Integer class can be used to convert an Integer object to primitive int type.(Choose the correct answer)
A.
B.
C.
D.
E.
4.  What gets printed when the following program is compiled and run? Select the one correct answer.class test { public static void main(String args[]) { int i; do { i++; } while(i < 0); System.out.println(i); }}
A.
B.
C.
D.
E.
5.  class c1{   public void m1()    {       System.out.println("m1 method in C1 class");     }}class c2{  public c1 m1()   {     return new c1(){       public void m1()          {              System.out.println("m1 mehod in anonymous class");    }};}public static void main(String a[]) {                c1 ob1 =new c2().m1();        ob1.m1();}}
A.
B.
C.
D.
E.
6.  class c2{{ System.out.println("initializer");}public static void main(String a[]){System.out.println("main"); c2 ob1=new c2();}}
A.
B.
C.
D.
7.  What will be the output if you compile and run the following code ?public class Main{ private static int i; public static void main(String[] args){ System.out.println(i); }}
A.
B.
C.
D.
E.
8.  What is the best way to findout the time/memory consuming process?
A.
B.
C.
D.
E.
9.  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.
10.  What is the number displayed when the following program is compiled and run.class test {    public static void main(String args[]) {        test test1 = new test();            System.out.println(test1.xyz(100));        }    public int xyz(int num) {        if(num == 1) return 1;        else return(xyz(num-1) + num);    }}
11.  +Which of the following is true regarding the continue statement in afor loop?
A.
B.
C.
D.
E.
12.  What will be the output if you compile and run the following code ?public class Main { public static void main(String[] args){ int vest[]=new int[]{1,2,3}; System.out.println(vest[1]); }}
A.
B.
C.
D.
E.
13.  1. StringBuffer s1 = new StringBuffer("abc");2. StringBuffer s2 = s1;3. StringBuffer s3 = new StringBuffer("abc");How many objects are created ?
A.
B.
C.
D.
14.  The Throwable class is the superclass of all exceptions in the Java language.
A.
B.
15.  What is the signature of the run() method of the Runnable interface?
A.
B.
C.
D.
16.  What gets printed when the following program is compiled and run? Select the one correct answer.class xyz {    static int i;    public static void main(String args[]) {        while (i < 0) {            i--;        }        System.out.println(i);    }}
A.
B.
C.
D.
E.
17.  How can you ensure that the memory allocated by an object is freed. Select the one correct answer
A.
B.
C.
D.
18.  Given the following declarations, which of the assignments given in the options below would compile. Select the two correct answers.int i = 5;boolean t = true;float f = 2.3F;double d = 2.3;
A.
B.
C.
D.
E.
19.  class C {public static void main(String[] args) {   char  c1=65;  switch(c1){       case 'A':                                             System.out.println("one");        default:                                             System.out.println("two");      case 'b':                                              System.out.println("three");}}}
A.
B.
C.
D.
E.
20.  What is the singleton access modifier ?
A.
B.
C.
D.
21.  What will happen when you attempt to compile and run the following code?class TestRunnable implements Runnable {    int k = 0;    public int run() {        while (true) {            k++;            System.out.print("k=" + k);        }        return 50;    }}
A.
B.
C.
D.
E.
22.  How would the number 5 be represented in hex using up-to four characters? ............
23.  abstract class vehicle{abstract public void speed();}class car extends vehicle{public static void main (String args[]) {vehicle ob1;        ob1=new car();   //1}}
A.
B.
C.
D.
24.  Given the following declarationsString s1=new String("1")String s2=new String("2");String s3=new String("true");String s3=new String("false");Which of the following are legal operations?
A.
B.
C.
D.
E.
25.  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. .........
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.  interface I{final class C1   {     //1       static int i=9;;  //2 }}class C2 implements I{ public static void main(String a[]){    System.out.println(I.C1.i);  ///3}}
A.
B.
C.
D.
E.
28.  Which of these are legal array declarations or definitions? Select the two correct answers.
A.
B.
C.
D.
29.  class C{public static void main(String a[]){C c1=new C();C c2=m1(c1);C c3=new C();c2=c3;              //6anothermethod();}static C m1(C ob1){ob1 =new C();return ob1;}}After line 6, how many objects are eligible for garbage collection?
A.
B.
C.
D.
30.  What will be the output if you compile and run the following code ?String str=new String("honey");int begin=1;int end=3;System.out.println(str.substring(begin,end));
A.
B.
C.
D.
E.
31.  class c1{public void m1(Object o1){  System.out.println("object");}public void m1(String o1){    System.out.println("string");}public int m1(int c){    return c;}public static void main(String a[]){   c1 ob1=new c1();   ob1.m1("hai");              }}
A.
B.
C.
D.
32.  Which of the following is true. Select the two correct answers
A.
B.
C.
D.
33.  The constructor for the Math class is private, so it cannot be instaniated
A.
B.
34.  Which of the following methods are static members of the Thread class?
A.
B.
C.
D.
E.
35.  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.
36.   Which of the following statements are true. Select the two correct answers
A.
B.
C.
D.
37.  class C{static String m(int i) {return "int";}static String m(float i) {return "float";}public static void main (String[] args) {long a1 = 1; double b1 = 2;System.out.print(m(a1)+","+ m(b1));}}
A.
B.
C.
D.
E.
38.  interface I{void f1();              // 1public void f2();       // 2protected void f3();    // 3private void f4();      // 4abstract void f5();     // 5}
A.
B.
C.
D.
E.
39.  In Java technology what expression can be used to represent number of elements in an array named arr ? ...........
40.  class C {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");}}}What is the result of attempting to compile and run the program? 
A.
B.
C.
D.
E.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz