Oracle Java Certified Programmer Sample Questions:
1. Which two can directly cause a thread to stop executing? (Choose Two)
A) Calling the notifyAll method on an object.
B) Calling the setPriority method on a thread object.
C) Exiting from a synchronized block.
D) Calling the notify method on an object.
E) Calling the wait method on an object.
2. Given:
1 . String foo = "blue";
2 . Boolean[]bar = new Boolean [1];
3 . if (bar[0]){
4 .foo = "green";
5 .}
What is the result?
A) An exception is thrown.
B) The code will not compile.
C) Foo has the value of ""
D) Foo has the value of null.
E) Foo has the value of "green"
F) Foo has the value of "blue"
3. Given:
Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);
Which two expressions evaluate to True? (Choose Two)
A) (i.equals (42))
B) (i.equals (d))
C) (d.equals (i))
D) (i == d)
E) (i ==1)
F) (d == 1)
4. Exhibit:
ClassOne.java
1. package com.abc.pkg1;
2. public class ClassOne {
3. private char var = 'a';
4. char getVar() {return var;}
5. } ClassTest.java
1 . package com.abc.pkg2;
2 . import com.abc.pkg1.ClassOne;
3 . public class ClassTest extends ClassOne {
4 . public static void main(String[]args){
5 .char a = new ClassOne().getVar();
6 .char b = new ClassTest().getVar();
7 .}
8 . }
What is the result?
A) Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
B) Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.
C) Compilation will fail.
D) Compilation succeeds and no exceptions are thrown.
5. Which method in the Thread class is used to create and launch a new thread of execution?
A) Execute();
B) Run(Runnable r);
C) Execute(Thread t);
D) Run();
E) Start();
F) Start(Runnable r);
Solutions:
| Question # 1 Answer: B,E | Question # 2 Answer: B | Question # 3 Answer: B,C | Question # 4 Answer: D | Question # 5 Answer: E |
We're so confident of our products that we provide no hassle product exchange.


By Antony

