We have sent an email with your new password.

Close this window

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.  abstract class C1{public void m1(){        //1}}abstract class C2{ public void m2(){      //2}}
A.
B.
C.
D.
2.  Which of the following statements related to Garbage Collection are correct. Select the two correct answers
A.
B.
C.
D.
3.  Which of the following methods are static members of the Thread class?
A.
B.
C.
D.
E.
4.  Which of these statements are true. (Choose all that apply)
A.
B.
C.
D.
E.
5.  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.
6.  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.
7.  What will happen if you attempt to compile and run the following code?.public class Main {    public static void main(String[] args) {        Main m = new Main();        m.m1();    }    public void m1() {        int ii = 012;        System.out.println(ii);    }}.............
8.  What gets printed when the following program is compiled and run? public class Main {    public void m1(Object o) {        System.out.println("Object");    }    public void m1(String s) {        System.out.println("String");    }    public static void main(String args[]) {        Main m = new Main();        m.m1(null);    }}
A.
B.
C.
D.
E.
9.  abstract class A {}   // 1transient class B {}  // 2private class C {}    // 3static class D {}     // 4Which of these declarations will not produce a compile-time error?
A.
B.
C.
D.
E.
10.  Which are valid Java keywords.(Choose all that apply)
A.
B.
C.
D.
E.
11.  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.
12.  class c1{public static void main(String a[]){    System.out.println(Double.NaN==Double.NaN);    System.out.println(Double.NaN!=Double.NaN);    System.out.println(Float.NaN==Double.NaN);}}
A.
B.
C.
D.
E.
13.  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.
14.  Assume that class A extends class B, which extends class C. Also all the three classes implement the method test(). How can a method in a class A invoke the test() method defined in class C (without creating a new instance of class C). Select the one correct answer
A.
B.
C.
D.
E.
15.  What is the signature of the run() method of the Runnable interface?
A.
B.
C.
D.
16.  What is the result of compiling and running the following program. Select the one correct answerclass test {    public static void main(String args[]) {        int[] arr = {1,2,3,4};        call_array(arr[0], arr);        System.out.println(arr[0] + "," + arr[1]);            }    static void call_array(int i, int arr[]) {        arr[i] = 6;        i = 5;    }    }
A.
B.
C.
D.
17.  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.
18.  To make a variable defined in a class accessible only to methods defined in the classes in same package, which of the following keyword should be used. Select the one correct answer
A.
B.
C.
D.
E.
19.  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.
20.  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.
21.  What is the number of bytes used by Java primitive long. Select the one correct answer.
A.
B.
C.
D.
E.
22.  interface I {           //1  public class Inner {   ///2                    Inner ( ) {                  System .out . println ( "Inner Created" ) ;          }  };};
A.
B.
C.
D.
23.  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.
24.  Which of the following are correct. Select the one correct answer.
A.
B.
C.
D.
25.  Class C {public static void main(String[] args) {  System.out.println(4+5+"String");}}
A.
B.
C.
D.
E.
26.  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.
27.  What is the best way to findout the time/memory consuming process?
A.
B.
C.
D.
E.
28.  class C {  private String get ( String str ) {          try          {                  throw new Exception ( ) ;                  return str ;          }          catch ( Exception e )          {                  return null ;          }  }  public static void main ( String peace [ ] ) {          try          {                  System.out.println ( ( new C ( ) ).get ( " C " ) ) ;          }          catch ( Exception e )          {                  System.out.println( "Exception" ) ;          }  }};
A.
B.
C.
D.
29.  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.
30.  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.
31.  class C{static int s;public static void main(String a[]){C obj=new C();obj.m1();System.out.println(s);}void m1();{int x=1;m2(x);System.out.println(x+"");}void m2(int x){x=x*2;s=x;}}
A.
B.
C.
D.
E.
32.  Which of the following classes  will not allow unsynchronized read operations by multiple threads?
A.
B.
C.
D.
E.
33.  Select the one correct answer. The smallest number that can be represented using short primitive type in Java is -
A.
B.
C.
D.
E.
34.  class C{public static void main (String[] args) {byte b1=33;              //1b1++;                    //2byte b2=55;              //3b2=b1+1;                 //4System.out.println(b1+""+b2);}}
A.
B.
C.
D.
E.
35.  What is the name of the Collection interface used to represent elements in a sequence (in a particular order). (Choose the correct answer)
A.
B.
C.
D.
E.
36.  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.
37.  What all gets printed when the following program is compiled and run. Select the one correct answer.      public class test {         public static void main(String args[]) {             int i=0, j=2;            do {               i=++i;               j--;            } while(j>0);            System.out.println(i);         }      }              
A.
B.
C.
D.
E.
38.  A program needs to store the name, salary, and age of employees in years. Which of the following data types should be used to create the Employee class. Select the three correct answer
A.
B.
C.
D.
E.
39.   Each element must be unique Duplicate elements must not replace old elements. Elements are not key/value pairs.Accessing an element can be almost as fast as performing a similar operation on an array.Which of these classes provide the specified features?
A.
B.
C.
D.
E.
40.  Using up to four characters what is the Java representation of the number 23 in hex?..............
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz