Thursday, September 15, 2011

Quiz of the day | OCPJP (10)

2. interface A { }
3. interface B { }
4. abstract interface C extends A, B {
5. void c();
6. }
7. class D implements C {
8. public void c() { System.out.print("c "); }
9. }
10. class E implements C extends D {
11. public void c() { System.out.print("c x "); }
12. }
13. public class F extends D implements C, B { }

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

A. Compilation succeeds.
B. Compilation fails because of error(s) in C.
C. Compilation fails because of error(s) in D.
D. Compilation fails because of error(s) in E.
E. Compilation fails because of error(s) in F.


DOWNLOAD the answer

Wednesday, September 14, 2011

Quiz of the day | OCPJP (9)

Which are true about a method-local inner class? (Choose all that apply.)

A. It must be marked final
B. It can be marked abstract
C. It can be marked public
D. It can be marked static
E. It can access private members of the enclosing class

DOWNLOAD the answer

Tuesday, September 13, 2011

Quiz of the day | OCPJP (8)

Given:

1. public class MyOffice {
2. public static void main(String[] args) {
3. String name = "PT";
4. name.concat("Time");
5. name = go(name);
6. System.out.println(name);
7. }
8. static String go(String name) {
9. name.concat("Excelindo");
10. return name;
11. } }

What is the result?
A. Time
B. PT
C. TimeExcelindo
D. PTTime
E. PTExcelindo
F. PTTimeExcelindo
G. Compilation fails.


DOWNLOAD the answer

Monday, September 12, 2011

Quiz of the day | OCPJP (7)

Given:

public class TimeExcelindo extends Thread {
public static void main(String[] args) {
Thread t = new Thread(new TimeExcelindo());
Thread t2 = new Thread(new TimeExcelindo());
t.start();
t2.start();
}
public static void run() {
for(int i = 0; i < 2; i++)
System.out.print(Thread.currentThread().getName() + " ");
}
}

Which are true? (Choose all that apply.)

A. Compilation fails.
B. No output is produced.
C. The output could be Thread-1 Thread-3 Thread-1 Thread-2
D. The output could be Thread-1 Thread-3 Thread-1 Thread-3
E. The output could be Thread-1 Thread-1 Thread-2 Thread-2
F. The output could be Thread-1 Thread-3 Thread-3 Thread-1
G. The output could be Thread-1 Thread-3 Thread-1 Thread-1


DOWNLOAD the answer

Sunday, September 11, 2011

Quiz of the day | OCPJP (6)

Given:

interface Beautiful { public void makeUp(); }

Which will compile? (Choose all that apply.)

A. public class Girl implements Beautiful { public void makeUp() { } }

B. public class Girl implements Beautiful { public void makeUp(int x) { } }

C. public class Girl implements Beautiful {
public void makeUp() { System.out.println("The girl is beautiful..."); }
}
D. public abstract class Girl implements Beautiful {
public void makeUp(int x) { }
}
E. public abstract class Girl implements Beautiful {
public void makeUp(int x) ;
}


DOWNLOAD the answer