Oracle 1Z0-851 Actual Free Exam Questions & Community Discussion
Given:
10.interface Data { public void load(); }
11.abstract class Info { public abstract void load(); }
Which class correctly uses the Data interface and Info class?
10.interface Data { public void load(); }
11.abstract class Info { public abstract void load(); }
Which class correctly uses the Data interface and Info class?
Correct Answer: C
Vote an answer
Given:
11.static class A {
12.void process() throws Exception { throw new Exception(); }
13.}
14.static class B extends A {
15.void process() { System.out.println("B"); }
16.}
17.public static void main(String[] args) {
18.new B().process();
19.}
What is the result?
11.static class A {
12.void process() throws Exception { throw new Exception(); }
13.}
14.static class B extends A {
15.void process() { System.out.println("B"); }
16.}
17.public static void main(String[] args) {
18.new B().process();
19.}
What is the result?
Correct Answer: A
Vote an answer
Given:
11.interface DeclareStuff {
12.public static final int EASY = 3;
13.void doStuff(int t); }
14.public class TestDeclare implements DeclareStuff {
15.public static void main(String [] args) {
16.int x = 5;
17.new TestDeclare().doStuff(++x);
18.}
19.void doStuff(int s) {
20.s += EASY + ++s;
21.System.out.println("s " + s);
22.}
23.}
What is the result?
11.interface DeclareStuff {
12.public static final int EASY = 3;
13.void doStuff(int t); }
14.public class TestDeclare implements DeclareStuff {
15.public static void main(String [] args) {
16.int x = 5;
17.new TestDeclare().doStuff(++x);
18.}
19.void doStuff(int s) {
20.s += EASY + ++s;
21.System.out.println("s " + s);
22.}
23.}
What is the result?
Correct Answer: A
Vote an answer
Given a method that must ensure that its parameter is not null:
11.public void someMethod(Object value) {
12.// check for null value ...
20.System.out.println(value.getClass());
21.}
What, inserted at line 12, is the appropriate way to handle a null value?
11.public void someMethod(Object value) {
12.// check for null value ...
20.System.out.println(value.getClass());
21.}
What, inserted at line 12, is the appropriate way to handle a null value?
Correct Answer: B
Vote an answer
A company that makes Computer Assisted Design (CAD) software has, within its application, some utility classes that are used to perform 3D rendering tasks. The company's chief scientist has just improved the performance of one of the utility classes' key rendering algorithms, and has assigned a programmer to replace the old algorithm with the new algorithm. When the programmer begins researching the utility classes, she is happy to discover that the algorithm to be replaced exists in only one class. The programmer reviews that class's API, and replaces the old algorithm with the new algorithm, being careful that her changes adhere strictly to the class's API. Once testing has begun, the programmer discovers that other classes that use the class she changed are no longer working properly. What design flaw is most likely the cause of these new bugs?
Correct Answer: F
Vote an answer
Given:
1.public class Donkey {
2.public static void main(String[] args) {
3.boolean assertsOn = false;
4.assert (assertsOn) : assertsOn = true;
5.if(assertsOn) {
6.System.out.println("assert is on");
7.}
8.}
9.}
If class Donkey is invoked twice, the first time without assertions enabled, and the second time
with assertions enabled, what are the results?
1.public class Donkey {
2.public static void main(String[] args) {
3.boolean assertsOn = false;
4.assert (assertsOn) : assertsOn = true;
5.if(assertsOn) {
6.System.out.println("assert is on");
7.}
8.}
9.}
If class Donkey is invoked twice, the first time without assertions enabled, and the second time
with assertions enabled, what are the results?
Correct Answer: D
Vote an answer
Given:
11.public class Person {
12.private name;
13.public Person(String name) {
14.this.name = name;
15.}
16.public int hashCode() {
17.return 420;
18.}
19.}
Which statement is true?
11.public class Person {
12.private name;
13.public Person(String name) {
14.this.name = name;
15.}
16.public int hashCode() {
17.return 420;
18.}
19.}
Which statement is true?
Correct Answer: D
Vote an answer
Given:
1.interface DoStuff2 {
2.float getRange(int low, int high); }
3.4.
interface DoMore {
5.float getAvg(int a, int b, int c); }
6.7.
abstract class DoAbstract implements DoStuff2, DoMore { }
8.9.
class DoStuff implements DoStuff2 {
10.public float getRange(int x, int y) { return 3.14f; } }
11.12.
interface DoAll extends DoMore {
13.float getAvg(int a, int b, int c, int d); } What is the result?
1.interface DoStuff2 {
2.float getRange(int low, int high); }
3.4.
interface DoMore {
5.float getAvg(int a, int b, int c); }
6.7.
abstract class DoAbstract implements DoStuff2, DoMore { }
8.9.
class DoStuff implements DoStuff2 {
10.public float getRange(int x, int y) { return 3.14f; } }
11.12.
interface DoAll extends DoMore {
13.float getAvg(int a, int b, int c, int d); } What is the result?
Correct Answer: E
Vote an answer
Given classes defined in two different files:
1.package util;
2.public class BitUtils {
3.public static void process(byte[] b) { /* more code here */ }
4.}
1.package app;
2.public class SomeApp {
3.public static void main(String[] args) {
4.byte[] bytes = new byte[256];
5.// insert code here
6.}
7.}
What is required at line 5 in class SomeApp to use the process method of BitUtils?
1.package util;
2.public class BitUtils {
3.public static void process(byte[] b) { /* more code here */ }
4.}
1.package app;
2.public class SomeApp {
3.public static void main(String[] args) {
4.byte[] bytes = new byte[256];
5.// insert code here
6.}
7.}
What is required at line 5 in class SomeApp to use the process method of BitUtils?
Correct Answer: A
Vote an answer
0
0
0
10







