Java 6 Test

40 Questions  I  By Pearlox
Java Quizzes & Trivia
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.  class base{base(int c){ System.out.println("base");}}class Super extends base{ Super() {    System.out.println("super");  }public static void main(String [] a){      base b1=new  Super();}}
A.
B.
C.
D.
3.  class C {  public static void main ( String ka [ ] ) {          while ( false ) {                  System.out.println ( "Value" ) ;          }  }}
A.
B.
C.
D.
4.  Is the following statement true or false. The constructor of a class must not have a return type.
A.
B.
5.  What is the best way to findout the time/memory consuming process?
A.
B.
C.
D.
E.
6.  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.
7.  +Which of the following is true regarding the continue statement in afor loop?
A.
B.
C.
D.
E.
8.  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.
9.  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.
10.  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.
11.   Which of the following statements are correct. Select the one correct answer
A.
B.
C.
D.
12.  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.
13.  The number of characters in an object of a class String is given by(Choose the correct answer)
A.
B.
C.
D.
E.
14.  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.
15.  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.
16.  The class Hashtable is used to implement which collection interface. Select the one correct answer.
A.
B.
C.
D.
E.
17.  interface I{void f1();              // 1public void f2();       // 2protected void f3();    // 3private void f4();      // 4abstract void f5();     // 5}
A.
B.
C.
D.
E.
18.  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.
19.  class C1{public void m1(){    // 1}}class C2 extends C1{ //2private void  m1(){   }}
A.
B.
C.
D.
20.  Which of the following are legal identifier names in Java. Select the two correct answers.
A.
B.
C.
D.
E.
21.  What gets printed when the following program is compiled and run. Select the one correct answer.public class incr {    public static void main(String args[]) {        int i , j;        i = j = 3;        int n = 2 * ++i;        int m = 2 * j++;        System.out.println(i + " " + j + " " + n + " " + m);    }}
A.
B.
C.
D.
E.
22.  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.
23.  Which keyword when applied on a method indicates that only one thread should execute the method at a time. Select the one correct answer
A.
B.
C.
D.
E.
24.  System.out.println("String".substring(0,4));This statement will Print
A.
B.
C.
D.
25.  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.
26.    boolean b1;  b1=3<4<5;                //1  System.out.println(b1);  //2}}]]>
A.
B.
C.
D.
27.  What gets printed when the following program is compiled and run? Select the one correct answer.class xyz {     public static void main(String args[]) {        int i,j,k;        for (i = 0; i < 3; i++) {            for(j=1; j < 4; j++) {                for(k=2; k<5; k++) {                    if((i == j)   && (j==k))                        System.out.println(i);                }                            }        }    }}
A.
B.
C.
D.
E.
28.  Name the collection interface used to represent collections that maintain unique elements..........
29.  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.
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.  An abstract class must have at least one abstract method
A.
B.
32.  You want to initialize all of the elements of a double array a to thesame value equal to 1.5.What could you write?Assume that the array has been correctly initialized
A.
B.
C.
D.
E.
33.  Which of these is a legal definition of a method named m assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer.
A.
B.
C.
D.
E.
34.  The constructor for the Math class is private, so it cannot be instaniated
A.
B.
35.  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.
36.  What is the signature of the run() method of the Runnable interface?
A.
B.
C.
D.
37.  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.
38.  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.
39.   Which are legal identifier names in Java. (Choose all that apply)
A.
B.
C.
D.
E.
40.  What is the default priority of a newly created thread
A.
B.
C.
D.
Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz
We have sent an email with your new password.