Java 6 Test

40 Questions  I  By Pearlox
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 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.
2.  Is the following statement true or false. The constructor of a class must not have a return type.
A.
B.
3.  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.
4.  Select the one most appropriate answer. What is the purpose of method parseInt defined in Integer class.
A.
B.
C.
D.
5.  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.
6.  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.
7.  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.
8.  In which all cases does an exception gets generated. Select the two correct answers int i = 0, j = 1;
A.
B.
C.
D.
9.  Which of the following methods are static members of the Thread class?
A.
B.
C.
D.
E.
10.  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.
11.  What is the default priority of a newly created thread
A.
B.
C.
D.
12.  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.
13.  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.
14.  Which of the following is true. Select the two correct answers
A.
B.
C.
D.
15.  What is the result of compiling and running the following program. Select the one correct answer.class test {    public static void main(String args[]) {        char ch;        String test2 = "abcd";        String test = new String("abcd");        if(test.equals(test2)) {            if(test == test2)                ch = test.charAt(0);            else                ch = test.charAt(1);                       }        else {            if(test == test2)                ch = test.charAt(2);            else                                ch = test.charAt(3);        }        System.out.println(ch);    }}
A.
B.
C.
D.
16.  abstract class C1{public void m1(){        //1}}abstract class C2{ public void m2(){      //2}}
A.
B.
C.
D.
17.  Is the following statement true or false. The constructor of a class must not have a return type.
A.
B.
18.  Which of the following are correct. Select the one correct answer.
A.
B.
C.
D.
19.  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.
20.  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.
21.  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.
22.  Which of these statements are true. (Choose all that apply)
A.
B.
C.
D.
E.
23.  How would you declare and initialize an array, palette, of Colorobjects of size 6?
A.
B.
C.
D.
E.
24.  StringBuffer objects once created can not be modified
A.
B.
25.  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);}}How many threads are created in this Program?
A.
B.
C.
D.
E.
26.  Name the return type of method hashCode() defined in Object class, which is used to get the unique hash value of an Object.
27.  class C{public static void main(String[] args) {  try    {        try           {               try                 {                   }                 catch(RuntimeException e)                 {                  }             }           catch(Exception e)           {            }                    }    catch(NullPointerException e)    {        }     finally    {              System.out.println("finally");       }}}
A.
B.
C.
D.
28.  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.
29.  What kind of thread is the Garbage collector thread?
A.
B.
C.
D.
E.
30.  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);    }}
31.  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.
32.  What is the result of evaluating the expression 14 ^ 23. Select the one correct answer
A.
B.
C.
D.
E.
33.  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.
34.  class C {  public static void main ( String ka [ ] ) {          Thread t = Thread . currentThread ( ) ;          t . setPriority ( - 1 ) ;          System . out . println ( " Done ! " ) ;  }};
A.
B.
C.
D.
35.  Which of the following statements about arrays are true.(Choose all that apply)
A.
B.
C.
D.
E.
36.  Name the collection interface used to represent collections that maintain unique elements..........
37.  class C{ public static void main(String a[])      {  int i1=9;  int i2;    if(i1>3) {                 i2=8;     }   System.out.println(i2);}}
A.
B.
C.
D.
E.
38.  What gets written on the screen when the following program is compiled and run. Select the one right answer.      public class test {         public static void main(String args[]) {          int i;         float  f = 2.3f;         double d = 2.7;         i = ((int)Math.ceil(f)) * ((int)Math.round(d));                System.out.println(i);         }      }
A.
B.
C.
D.
E.
39.  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.
40.  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.
Back to top


to post comments.

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz