QUESTION 31
Click the Exhibit button. Given the fully-qualified class names:
Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM?
Exhibit:
A. Jar A
B. Jar B
C. Jar C
D. Jar D
E. Jar E
Correct Answer: A Section: All Explanation
Explanation/Reference:
QUESTION 32
Given:
public class ClassA { public void methodA() {
ClassB classB = new ClassB(); classB.getValue();
}
}
class ClassB {
public ClassC classC;
public String getValue() { return classC.getValue();
}
}
class ClassC {
public String value;
public String getValue() { value = "ClassB"; return value;
}
}
and:
ClassA a = new ClassA(); a.methodA();
What is the result?
A. Compilation fails.
B. ClassC is displayed.
C. The code runs with no output.
D. An exception is thrown at runtime.
Correct Answer: D Section: All Explanation
Explanation/Reference:
QUESTION 33
Given:
09. interface Foo { int bar(); } 10.
11. public class Sprite {
12. public int fubar( Foo foo ) { return foo.bar(); }
13. public void testFoo() {
14. fubar(
15. //insert code here 15 16. );
17. }
18. }
Which code, inserted at line 15, allows the class Sprite to compile?
A. Foo { public int bar() { return 1; }
B. new Foo { public int bar() { return 1; }
C. new Foo() { public int bar() { return 1; }
D. new class Foo { public int bar() { return 1; }
Correct Answer: C Section: All Explanation
Explanation/Reference:
QUESTION 34
Given:
11. public enum Title {
12. MR("Mr."), MRS("Mrs."), MS("Ms.");
13. private final String title;
14. private Title(String t) { title = t; }
15. public String format(String last, String first) {
16. return title + " " + first + " " + last;
17. }
18. } 19.
20. public static void main(String[] args) {
21. System.out.println(Title.MR.format("Doe", "John"));
22. }
What is the result?
A. Mr. John Doe
B. An exception is thrown at runtime.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 21.
Correct Answer: A Section: All Explanation
Explanation/Reference:
QUESTION 35
Given the following six method names:
How many of these method names follow JavaBean Listener naming rules?
A. 1
B. 2
C. 3
D. 4
E. 5
Correct Answer: B Section: All Explanation
Explanation/Reference:
Listener method names used to "register" a listener with an event source must use the prefix add , followed by the listener type. For example, addActionzistener() is a valid name for a method that an event source will have to allow others to register for Action events.
Listener method names used to remove ("unregister") a listener must use the prefix remove , followed by the listener type (using the same rules as the registration add method).
QUESTION 36
Given:
9. class Line {
10. public static class Point {}
11. } 12.
13. class Triangle {
14. public Triangle(){
15. // insert code here
16. }
17. }
Which code, inserted at line 15, creates an instance of the Point class defined in Line?
A. Point p = new Point();
B. Line.Point p = new Line.Point();
C. The Point class cannot be instatiated at line 15.
D. Line l = new Line(); l.Point p = new l.Point();
Correct Answer: B Section: All Explanation
Explanation/Reference:
QUESTION 37
Given
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
Which three are valid on line 12? (Choose three.)
A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected
Correct Answer: ABD Section: All Explanation
Explanation/Reference:
QUESTION 38
Given:
public class A{
private int counter = 0;
public static int getInstanceCount() {
return counter;
}
public A() {
counter++;
}
}
Given this code from Class B:
25. A a1 = new A();
26. A a2 = new A();
27. A a3 = new A();
28. System.out.println(A.getInstanceCount());
What is the result?
A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. A runtime error occurs when line 25 executes.
E. Compilation fails because of an error on line 28.
Correct Answer: A Section: All Explanation
Explanation/Reference:
Cannot make a static reference to the non-static field counter
QUESTION 39
Given classes defined in two different files:
package util;
public class BitUtils {
public static void process(byte[] b) { /* more code here */ }
}
1. package app;
2.
3. public class SomeApp {
4. public static void main(String[] args) {
5. byte[] bytes = new byte[256];
6. // insert code here
7. }
8. }
What is required at line 6 in class SomeApp to use the process method of BitUtils?
A. process(bytes);
B. BitUtils.process(bytes);
C. util.BitUtils.process(bytes);
D. SomeApp cannot use methods in BitUtils.
E. import util.BitUtils.*; process(bytes);
Correct Answer: C Section: All Explanation
Explanation/Reference:
QUESTION 40
Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
10. class Inner {
11. private int x;
12. public void setX( int x ){ this.x = x; }
13. public int getX(){ return x;}
14. } 15.
16. class Outer {
17. private Inner y;
18. public void setY( Inner y ){ this.y = y; }
19. public Inner getY() { return y; }
20. } 21.
22. public class Gamma {
23. public static void main(String[] args) {
24. Outer o = new Outer();
25. Inner i = new Inner();
26. int n = 10;
27. |
|
i.setX(n); |
28. |
|
o.setY(i); |
29. |
|
// insert code here |
30. |
|
System.out.println(o.getY().getX()); |
31. |
} |
|
32.} |
|
|
A. n = 100;
B. i.setX( 100 );
C. o.getY().setX( 100 );
D. i = new Inner(); i.setX( 100 );
E. o.setY( i );
i = new Inner(); i.setX( 100 );
F. i = new Inner(); i.setX( 100 ); o.setY( i );
Correct Answer: BCF Section: All Explanation
Explanation/Reference:
Source from : Oracle.Exactexams.1z0-851.v2013-11-27.by.SomeBody ().pdf
'Certificate > OCAJP' 카테고리의 다른 글
[1Z0-851C] Question 11~20 (0) | 2017.08.12 |
---|---|
[1Z0-851C] Question 01~10 (0) | 2017.08.12 |
[1Z0-851B] Question 51~60 (0) | 2017.08.11 |
[1Z0-851B] Question 41~50 (0) | 2017.08.11 |
[1Z0-851B] Question 21~30 (0) | 2017.08.11 |
[1Z0-851B] Question 11~20 (0) | 2017.08.11 |
[1Z0-851B] Question 01~10 (0) | 2017.08.11 |
[1Z0-851A] Question 51~60 (0) | 2017.08.05 |