Java 6 Test

40 Questions  I  By Pearlox
Please take the quiz to rate it.

Java Quizzes & Trivia
Pearlox Corp. Java 6 Test

  
Changes are done, please start the quiz.


Questions and Answers

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 ?(Choose the correct answer)public class test {   public static void main(String args[]) {       String str1="abc";      String str2="def";      String str3=str1.concat(str2);      str1.concat(str2);      System.out.println(str1);   }}
A.
B.
C.
D.
E.
2.  The number of characters in an object of a class String is given by(Choose the correct answer)
A.
B.
C.
D.
E.
3.  Which method defined in Integer class can be used to convert an Integer object to primitive int type.(Choose the correct answer)
A.
B.
C.
D.
E.
4.  Which are valid Java keywords.(Choose all that apply)
A.
B.
C.
D.
E.
5.  What is the number of bytes used by the primitive type long. (Select the best answer)
A.
B.
C.
D.
E.
6.  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.
7.  Which of the following statements about arrays are true.(Choose all that apply)
A.
B.
C.
D.
E.
8.  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.
9.  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.
10.  What will be the output if you compile and run the following code ?public class Main {    public static void main(String[] arg) {    method1(arg);    }    public void method1(String... arguments) {    System.out.println(arguments);    }}
A.
B.
C.
D.
E.
11.  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.
12.  What will be the output if you compile and run the following code ?public class Main { public static void main(String[] args){ int vest[]=new int[]{1,2,3}; System.out.println(vest[1]); }}
A.
B.
C.
D.
E.
13.  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.
14.  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.
15.  What will be the output if you compile and run the following code ?int i=1; switch (i) { case 0: System.out.println("number"); break; case 1: System.out.println("one"); case 5: System.out.println("two");case 10: System.out.println("three"); default: System.out.println("default"); }
A.
B.
C.
D.
E.
16.  What will be the output if you compile and run the following code ?int h=15;switch (h) {         default:         System.out.println("default");         case 20:         System.out.println("20");         break;         case 21:         System.out.println("21");         case 22:         System.out.println("22");        }
A.
B.
C.
D.
E.
17.  Which of the following statements are correct ?
A.
B.
C.
D.
E.
18.  Which of the following methods can be legally inserted in place of the comment //Insert Method Here ..class Main{ public void method1(int i) { }}public class Sub extends Main{ public static void main(String[] args){ } //Insert Method Here ..}
A.
B.
C.
D.
E.
19.  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.
20.  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.
21.  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.
22.  Which of the following statements about this code are true?class Testing extends Thread{    public void run(){        for(int i =0; i < 2; i++){            System.out.println(i);        }        }    }public class Sub{    public static void main(String[] args){        Sub m = new Sub();        m.go(new Testing());        }    public void go(Testing t){        t.start();        }    }
A.
B.
C.
D.
E.
23.   What will happen if you attempt to compile and run the following code?.public class Main {    static int j = 20;    public static void main(String[] args) {        int i = 10;        Main m = new Main();        m.m1(i);        System.out.println(i);        System.out.println(j);    }    public void m1(int x) {        x = x * 2;        j = j * 2;    }}
A.
B.
C.
D.
E.
24.  What will happen if you attempt to compile and run the following code?.public class Main {    public static void main(String[] args) {        Main m = new Main();        m.m1();    }    public void m1() {        int ii = 012;        System.out.println(ii);    }}.............
25.  You have a requirement to create a class that will store unique object elements. And you do not need to sort these elements.Which interface might be most suitable to meet your requirement?
A.
B.
C.
D.
E.
26.  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.
27.  Which declares a valid main method. (Choose all that apply)
A.
B.
C.
D.
E.
28.  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.
29.  Which defines a legal method declaration ?(Choose all that apply)
A.
B.
C.
D.
E.
30.   Which are legal identifier names in Java. (Choose all that apply)
A.
B.
C.
D.
E.
31.  void method() { }Which of the following declares a legal override of this method in a sub class.(Choose all that apply)
A.
B.
C.
D.
E.
32.  Which keyword when applied on a method indicates that only one thread can execute this method at a time. (Choose the correct answer)
A.
B.
C.
D.
E.
33.  Which of these statements are true. (Choose all that apply)
A.
B.
C.
D.
E.
34.  What gets printed when the following program is compiled and run? (Choose the correct answer)class Main {    public static void main(String[] args) {        int i;        do {            i++;        }        while(i < 0);        System.out.println(i);    }}
A.
B.
C.
D.
E.
35.  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.
36.  What gets printed when the following program is compiled and run? public class Main {    public void m1(Object o) {        System.out.println("Object");    }    public void m1(String s) {        System.out.println("String");    }    public static void main(String args[]) {        Main m = new Main();        m.m1(null);    }}
A.
B.
C.
D.
E.
37.  What kind of thread is the Garbage collector thread?
A.
B.
C.
D.
E.
38.  What kind of objects is StringBuffer ?
A.
B.
C.
D.
E.
39.  What Locale object represent?
A.
B.
C.
D.
E.
40.  What is the best way to findout the time/memory consuming process?
A.
B.
C.
D.
E.
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.