Oracle 1Z0-853 Actual Free Exam Questions & Community Discussion
Given:
10.
interface A { public int getValue(); }
11.
class B implements A {
12.
public int getValue() { return 1; }
13.
}
14.
class C extends B {
15.
// insert code here
16.
}
Which three code fragments, inserted individually at line 15, make use of polymorphism? (Choose three.)
10.
interface A { public int getValue(); }
11.
class B implements A {
12.
public int getValue() { return 1; }
13.
}
14.
class C extends B {
15.
// insert code here
16.
}
Which three code fragments, inserted individually at line 15, make use of polymorphism? (Choose three.)
Correct Answer: B,C,E
Vote an answer
Given:
11.
class A {
12.
public void process() { System.out.print("A,"); }
13.
class B extends A {
14.
public void process() throws IOException {
15.
super.process();
16.
System.out.print("B,");
17.
throw new IOException();
18.
}
19.
public static void main(String[] args) {
20.
try { new B().process(); }
21.
catch (IOException e) { System.out.println("Exception"); }
What is the result?
11.
class A {
12.
public void process() { System.out.print("A,"); }
13.
class B extends A {
14.
public void process() throws IOException {
15.
super.process();
16.
System.out.print("B,");
17.
throw new IOException();
18.
}
19.
public static void main(String[] args) {
20.
try { new B().process(); }
21.
catch (IOException e) { System.out.println("Exception"); }
What is the result?
Correct Answer: D
Vote an answer
Which two classes correctly implement both the java.lang.Runnable and the
java.lang.Clonable interfaces? (Choose two.)
java.lang.Clonable interfaces? (Choose two.)
Correct Answer: B,C
Vote an answer
Given:
10. interface Jumper { public void jump(); } ...
20. class Animal {} ...
30.
class Dog extends Animal {
31.
Tail tail;
32.
} ...
40.
class Beagle extends Dog implements Jumper{
41.
public void jump() {}
42.
} ...
50.
class Cat implements Jumper{
51.
public void jump() {}
52.
}
Which three are true? (Choose three.)
10. interface Jumper { public void jump(); } ...
20. class Animal {} ...
30.
class Dog extends Animal {
31.
Tail tail;
32.
} ...
40.
class Beagle extends Dog implements Jumper{
41.
public void jump() {}
42.
} ...
50.
class Cat implements Jumper{
51.
public void jump() {}
52.
}
Which three are true? (Choose three.)
Correct Answer: B,C,F
Vote an answer
Given a class Repetition:
1.package utils;
2.3.
public class Repetition {
4.public static String twice(String s) { return s + s; }
5.}
and given another class Demo:
1.// insert code here
2.3.
public class Demo {
4.public static void main(String[] args) {
5.System.out.println(twice("pizza"));
6.}
7.}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?
1.package utils;
2.3.
public class Repetition {
4.public static String twice(String s) { return s + s; }
5.}
and given another class Demo:
1.// insert code here
2.3.
public class Demo {
4.public static void main(String[] args) {
5.System.out.println(twice("pizza"));
6.}
7.}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?
Correct Answer: E
Vote an answer
Given:
11.
class Animal { public String noise() { return "peep"; } }
12.
class Dog extends Animal {
13.
public String noise() { return "bark"; }
14.
}
15.
class Cat extends Animal {
16.
public String noise() { return "meow"; }
17.
} ...
30.
Animal animal = new Dog();
31.
Cat cat = (Cat)animal;
32.
System.out.println(cat.noise());
What is the result?
11.
class Animal { public String noise() { return "peep"; } }
12.
class Dog extends Animal {
13.
public String noise() { return "bark"; }
14.
}
15.
class Cat extends Animal {
16.
public String noise() { return "meow"; }
17.
} ...
30.
Animal animal = new Dog();
31.
Cat cat = (Cat)animal;
32.
System.out.println(cat.noise());
What is the result?
Correct Answer: E
Vote an answer
Given:
10.
abstract class A {
11.
abstract void a1();
12.
void a2() { }
13.
}
14.
class B extends A {
15.
void a1() { }
16.
void a2() { }
17.
}
18.
class C extends B { void c1() { } }
and:
A x = new B(); C y = new C(); A z = new C();
What are four valid examples of polymorphic method calls? (Choose four.)
10.
abstract class A {
11.
abstract void a1();
12.
void a2() { }
13.
}
14.
class B extends A {
15.
void a1() { }
16.
void a2() { }
17.
}
18.
class C extends B { void c1() { } }
and:
A x = new B(); C y = new C(); A z = new C();
What are four valid examples of polymorphic method calls? (Choose four.)
Correct Answer: A,B,C,E
Vote an answer
Given:
10.
public class Bar {
11.
static void foo( int... x ) {
12.
// insert code here
13.
}
14.
}
Which two code fragments, inserted independently at line 12, will allow the class to compile? (Choose two.)
10.
public class Bar {
11.
static void foo( int... x ) {
12.
// insert code here
13.
}
14.
}
Which two code fragments, inserted independently at line 12, will allow the class to compile? (Choose two.)
Correct Answer: A,C
Vote an answer
Given:
1.public class Blip {
2.protected int blipvert(int x) { return 0; }
3.}
4.class Vert extends Blip {
5.// insert code here
6.}
Which five methods, inserted independently at line 5, will compile? (Choose five.)
1.public class Blip {
2.protected int blipvert(int x) { return 0; }
3.}
4.class Vert extends Blip {
5.// insert code here
6.}
Which five methods, inserted independently at line 5, will compile? (Choose five.)
Correct Answer: A,B,C,E,G
Vote an answer
Given:
1.public class TestSeven extends Thread {
2.private static int x;
3.public synchronized void doThings() {
4.int current = x;
5.current++;
6.x = current;
7.}
8.public void run() {
9.doThings();
10.
}
11.}
Which statement is true?
1.public class TestSeven extends Thread {
2.private static int x;
3.public synchronized void doThings() {
4.int current = x;
5.current++;
6.x = current;
7.}
8.public void run() {
9.doThings();
10.
}
11.}
Which statement is true?
Correct Answer: D
Vote an answer
Given:
10.
abstract public class Employee {
11.
protected abstract double getSalesAmount();
12.
public double getCommision() {
13.
return getSalesAmount() * 0.15;
14.
}
15.
}
16.
class Sales extends Employee {
17.
// insert method here
18.
}
Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.)
10.
abstract public class Employee {
11.
protected abstract double getSalesAmount();
12.
public double getCommision() {
13.
return getSalesAmount() * 0.15;
14.
}
15.
}
16.
class Sales extends Employee {
17.
// insert method here
18.
}
Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.)
Correct Answer: A,D
Vote an answer
0
0
0
10






