Oracle Java Certified Programmer Sample Questions:
1. Which four types of objects can be thrown using the throw statement? (Choose Four)
A) RuntimeException
B) Throwable
C) Exception
D) Event
E) Object
F) Error
2. CORRECT TEXT
Given:
8 . int index = 1;
9 . String [] test = new String[3];
1 0. String foo = test[index];
What is the result?
E.Foo has the value ""
B.Foo has the value null
C.An exception is thrown
D.The code will not compile
3. Given:
1 . public class foo {
2 . public static void main (string[]args)
3 . try {return;}
4 . finally {system.out.printIn("Finally");}
5 . }
6 . )
What is the result?
A) The code compiles, but an exception is thrown at runtime.
B) The program runs and prints "Finally"
C) The code will not compile because the catch block is missing.
D) The program runs and prints nothing.
4. CORRECT TEXT
Given:
AnInterface is an interface.
AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.
AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.
Which two construct an anonymous inner class? (Choose Two)
F.AnAdapter1 aa=new AnAdapter1(){}
G.AnAdapter0 aa=new AnAdapter0(){}
H.AnAdapter0 aa=new AnAdapter0(5){}
I.AnAdapter1 aa=new AnAdapter1(5){}
J.AnInterface a1=new AnInterface(5){}
5. Given:
1 . public class ArrayTest {
2 . public static void main (String[]args){
3 . float f1[], f2[];
4 . f1 = new float [10];
5 . f2 = f1;
6 . System.out.printIn ("f2[0]=" + f2[0]);
7 .}
8 .}
What is the result?
A) An error at line 6 causes an exception at runtime.
B) An error at line 5 causes compile to fail.
C) It prints f2[0] = 0.0
D) It prints f2[0] = NaN
E) An error at line 6 causes compile to fail.
Solutions:
| Question # 1 Answer: A,B,C,F | Question # 2 Answer: Only visible for members | Question # 3 Answer: B | Question # 4 Answer: Only visible for members | Question # 5 Answer: C |

We're so confident of our products that we provide no hassle product exchange.


By Bennett


