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.  class C1{static class C2{static int i1;}public static void main(String a[]){System.out.println(C1.C2.i1);}}What is the result of attempting to compile and run the program?
A.
B.
C.
D.
2.   Which are legal identifier names in Java. (Choose all that apply)
A.
B.
C.
D.
E.
3.  interface I{void f1();              // 1public void f2();       // 2protected void f3();    // 3private void f4();      // 4abstract void f5();     // 5}
A.
B.
C.
D.
E.
4.  class C{public static void main (String[] args) {String s1="hjhh";        // 1String s2="\u0002";      //2String s3="'\\'";        //3}}
A.
B.
C.
D.
E.
5.  class C {  public static void main ( String ka [ ] ) {          Thread t = Thread . currentThread ( ) ;          t . setPriority ( - 1 ) ;          System . out . println ( " Done ! " ) ;  }};
A.
B.
C.
D.
6.  class C {public static void main(String[] args) { int x=2; int y=3;   if((y==x++)|(x<++y)){                              System.out.println(x+""+y);        }}}
A.
B.
C.
D.
E.
7.  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.
8.  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.
9.  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.
10.  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.
11.  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.
12.  class c1 extends Exception{}class c2{   static void m1()    {       throw new c1();     }  public static void main(String a[])   {              }}
A.
B.
C.
D.
13.  class C{int i;public static void main (String[] args) {int i; //1private int a = 1; //2protected int b = 1; //3public int c = 1; //4System.out.println(a+b+c); //5}}
A.
B.
C.
D.
E.
14.  The constructor for the Math class is private, so it cannot be instaniated
A.
B.
15.  Which of the following are legal array declarations. Select the three correct answers
A.
B.
C.
D.
E.
16.  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.
17.  class c1{static{System.out.println("static");}public static void main(String a[]){System.out.println("main");}}
A.
B.
C.
D.
E.
18.  Select the one correct answer. The smallest number that can be represented using short primitive type in Java is -
A.
B.
C.
D.
E.
19.  When a byte is added to a char, what is the type of the result?
A.
B.
C.
D.
20.  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.
21.  import java.util.*;class  C{  final Vector v;  C()  {          v=new Vector();  }   C(int i)  {         }  public void someMethod()  {          System.out.println(v.isEmpty());  }}
A.
B.
C.
D.
22.  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.
23.  A signed data type has an equal number of non-zero positive and negative values available
A.
B.
24.   Which of the following statements are true. Select the two correct answers
A.
B.
C.
D.
25.  What kind of thread is the Garbage collector thread?
A.
B.
C.
D.
E.
26.  What is the number of bytes used by the primitive type long. (Select the best answer)
A.
B.
C.
D.
E.
27.  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.
28.   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.
29.  class C1{public void m1(){    // 1}}class C2 extends C1{ //2private void  m1(){   }}
A.
B.
C.
D.
30.  Is the following statement true or false. The constructor of a class must not have a return type.
A.
B.
31.  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.
32.  Select the one most appropriate answer. What is the purpose of method parseInt defined in Integer class.
A.
B.
C.
D.
33.  String objects once created can not be modified
A.
B.
34.    boolean b1;  b1=3<4<5;                //1  System.out.println(b1);  //2}}]]>
A.
B.
C.
D.
35.  The documentation of a class lists a method castToIntArray that has adouble array as a formal parameter and returns an array of integers.What is the signature of the method?
A.
B.
C.
D.
E.
36.  How can you ensure that the memory allocated by an object is freed. Select the one correct answer
A.
B.
C.
D.
37.  System.out.println("String".substring(0,4));This statement will Print
A.
B.
C.
D.
38.  class command {public static void main (String[] a1) {System.out.println(a1.length());         //1System.out.println(a1[0]);               //2System.out.println(a1);                  //3        //2}}
A.
B.
C.
D.
39.  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.
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