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.   Which of the following are true. Select the one correct answers
A.
B.
C.
D.
2.  What is the range of values that can be specified for an int. Select the one correct answer.
A.
B.
C.
D.
E.
3.  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.
4.   Name the access modifier which when used with a method, makes it available to all the classes in the same package and to all the subclasses of the class.
5.  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.
6.  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.
7.  When a byte is added to a char, what is the type of the result?
A.
B.
C.
D.
8.  if("String".replace('t','T') == "String".replace('t','T'))System.out.println("Equal");elseSystem.out.println("Not Equal");
A.
B.
C.
D.
9.  What Locale object represent?
A.
B.
C.
D.
E.
10.  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.
11.  Which of the following are legal array declarations. Select the three correct answers
A.
B.
C.
D.
E.
12.  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.
13.  What is the return type of method round(double d) defined in Math class.........
14.  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.
15.  Which declares a valid main method. (Choose all that apply)
A.
B.
C.
D.
E.
16.  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.
17.  Select the one correct answer. The number of characters in an object of a class String is given by
A.
B.
C.
D.
18.  Which of the following statements related to Garbage Collection are correct. Select the two correct answers
A.
B.
C.
D.
19.  What is the number of bytes used by Java primitive long. Select the one correct answer.
A.
B.
C.
D.
E.
20.   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.
21.   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.
22.  What is the best way to findout the time/memory consuming process?
A.
B.
C.
D.
E.
23.  Which of the following statements about arrays are true.(Choose all that apply)
A.
B.
C.
D.
E.
24.  class C {  public static void main ( String ka [ ] ) {          while ( false ) {                  System.out.println ( "Value" ) ;          }  }}
A.
B.
C.
D.
25.  Which of these are legal array declarations or definitions? Select the two correct answers.
A.
B.
C.
D.
26.  class H {  public static void main (String[] args) {    String s1 = "HHH";    StringBuffer sb2 = new StringBuffer(s1);    System.out.print(sb2.equals(s1) + "," + s1.equals(sb2));}}
A.
B.
C.
D.
E.
27.  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.
28.  interface I {           //1  public class Inner {   ///2                    Inner ( ) {                  System .out . println ( "Inner Created" ) ;          }  };};
A.
B.
C.
D.
29.    boolean b1;  b1=3<4<5;                //1  System.out.println(b1);  //2}}]]>
A.
B.
C.
D.
30.  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.
31.  Which of the following is true. Select the two correct answers
A.
B.
C.
D.
32.    19. 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 = "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.
33.  Name the collection interface used to represent a sequence of numbers in a fixed order
34.  interface I{int i;                            // line 1}class C implements I{public static void main(String a[]){   System.out.println(i);   System.out.println(i++);  //line 2}}
A.
B.
C.
D.
35.  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.
36.  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.
37.  Which of these statements are true. Select the two correct answers
A.
B.
C.
D.
38.  What all gets printed when the following code is compiled and run. Select the three correct answers.class test {    public static void main(String args[]) {        int i[] = {0,1};        try {            i[2] = i[0] + i[1];        }        catch(ArrayIndexOutOfBoundsException e1) {            System.out.println("1");        }        catch(Exception e2) {            System.out.println("2");        }        finally {            System.out.println(3);        }        System.out.println("4");       }}
A.
B.
C.
D.
39.  What will be the output if you compile and run the following code ?public class Test { public static void main(String[] arg){ int anar[]=new int[5]; System.out.println(anar[0]); }}
A.
B.
C.
D.
E.
40.  Which defines a legal method declaration ?(Choose all that apply)
A.
B.
C.
D.
E.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz