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 is the number of bytes used by the primitive type long. (Select the best answer)
A.
B.
C.
D.
E.
2.  In which all cases does an exception gets generated. Select the two correct answers int i = 0, j = 1;
A.
B.
C.
D.
3.  Name the return type of method hashCode() defined in Object class, which is used to get the unique hash value of an Object.
4.  String s = new String("xyz");      Assuming the above declaration, which of the following statements would compile. Select the one correct answer
A.
B.
C.
D.
E.
5.  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.
6.   Which are legal identifier names in Java. (Choose all that apply)
A.
B.
C.
D.
E.
7.  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.
8.  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.
9.  When a byte is added to a char, what is the type of the result?
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 c2{final int i1;c2(){i1=i1+1;}{i1=2;}public static void main(String a[]){c2 ob1=new c2();System.out.println(ob1.i1);}}
A.
B.
C.
D.
12.   Which of the following are true. Select the one correct answers
A.
B.
C.
D.
13.  How would you declare and initialize an array, palette, of Colorobjects of size 6?
A.
B.
C.
D.
E.
14.  Using up to four characters what is the Java representation of the number 23 in hex?..............
15.  How would the number 5 be represented in hex using up-to four characters? ............
16.  class C {public static void main(String[] args) {  try    {        int i1=3/0;      }       System.out.println("hai");    catch(NullpointerException e)    {        }     finally    {              System.out.println("finally);       }}}
A.
B.
C.
D.
17.  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.
18.  Which of the following is true. Select the two correct answers
A.
B.
C.
D.
19.  The relationship between a class and its superclass is
A.
B.
C.
20.  Public static double sin(double angle)What are the units of the "angle" argument?
A.
B.
C.
D.
21.  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.
22.  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.
23.  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.
24.  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.
25.  Which declares a valid main method. (Choose all that apply)
A.
B.
C.
D.
E.
26.  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.
27.  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.
28.  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.
29.  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.
30.  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.
31.  Given the following declarations, which of the assignments given below would compile.(Choose all that apply)int k = 20;boolean b = true;float f = 2.5F;double d = 2.5;
A.
B.
C.
D.
E.
32.  Which of the following statements are true. Select the one correct answer.
A.
B.
C.
D.
33.  What kind of thread is the Garbage collector thread?
A.
B.
C.
D.
E.
34.  What all gets printed when the following program is compiled and run. Select the two correct answers.      public class test {         public static void main(String args[]) {             int i, j=1;            i = (j>1)?2:1;            switch(i) {              case 0: System.out.println(0); break;              case 1: System.out.println(1);              case 2: System.out.println(2); break;              case 3: System.out.println(3); break;            }         }      }             
A.
B.
C.
D.
35.  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.
36.   In implementing two classes Employee and Manager, such that each Manager is an Employee, what should be the relationship between these classes. Select the one correct answer.
A.
B.
C.
D.
E.
37.  class C1{static interface I{static class C2{}}public static void main(String a[]){C1.I.C2 ob1=new C1.I.C2();System.out.println("object created");}}What is the result of attempting to compile and run the program?
A.
B.
C.
D.
38.  Which of the following statements related to Garbage Collection are correct. Select the two correct answers
A.
B.
C.
D.
39.  if("String".replace('t','T') == "String".replace('t','T'))System.out.println("Equal");elseSystem.out.println("Not Equal");
A.
B.
C.
D.
40.  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.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz