Monday, October 24, 2011

Quiz of the Day | OCPJP (35)

Given:

7. public interface Ndesit {
8. /* insert code here */ int score = 8;
9. }

Which 3 are valid on line 8? (Choose 3)
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected

Sunday, October 9, 2011

Quiz of the day | OCPJP (34)

Given:

3. class K {
4. String name = "kentang ";
5. String makeNoise() { return "ngentang"; }
6. }
7. class S extends K {
8. String name = "surikoyo ";
9. String makeNoise() { return "nyurikoyo"; }
10. }
11. public class ZK {
12. public static void main(String[] args) { new ZK().go(); }
13. void go() {
14. K k = new S();
15. System.out.println(k.name + k.makeNoise());
16. }
17. }

What is the result?

A. kentang nyurikoyo
B. surikoyo nyurikoyo
C. kentang ngentang
D. surikoyo ngentang
E. Compilation fails
F. An exception is thrown at runtime

Saturday, October 8, 2011

Quiz of the day | OCPJP (33)

Given:

1. public class Tingting implements Ayu
{ public void doIt() { } }
2.
3. abstract class Phone1 extends Electronic { }
4.
5. abstract class Phone2 extends Electronic
{ public void doIt(int x) { } }
6.
7. class Phone3 extends Electronic implements Ayu
{ public void doStuff() { } }
8.
9. interface Device { public void doIt(); }

What is the result? (Choose all that apply.)

A. Compilation succeeds
B. Compilation fails with an error on line 1
C. Compilation fails with an error on line 3
D. Compilation fails with an error on line 5
E. Compilation fails with an error on line 7
F. Compilation fails with an error on line 9

DOWNLOAD the answer

Friday, October 7, 2011

Quiz of the day | OCPJP (32)

Given:

1. class Pocong {
2. public static void main(String[] args) {
3. doStuff(8);
4. doStuff(8,9);
5. }
6. // insert code here
7. }

Which, inserted independently at line 6, will compile? (Choose all that

apply.)

A. static void doStuff(int... doArgs) { }
B. static void doStuff(int[] doArgs) { }
C. static void doStuff(int doArgs...) { }
D. static void doStuff(int... doArgs, int y) { }
E. static void doStuff(int x, int... doArgs) { }


DOWNLOAD the answer

Thursday, October 6, 2011

Quiz of the day | OCPJP (31)

Which method names follow the JavaBeans standard? (Choose all that apply.)

A. addBook
B. getProduct
C. deleteShirt
D. isThree
E. putBall


DOWNLOAD the answer