Oracle 1z0-851 Exam Practice Questions (P. 4)
- Full Access (260 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #16
Given:
01. public class Blip {
02. protected int blipvert(int x) { return 0; }
03. }
04. class Vert extends Blip {
05. // insert code here
06. }
Which five methods, inserted independently at line 5, will compile? (Choose five.)
01. public class Blip {
02. protected int blipvert(int x) { return 0; }
03. }
04. class Vert extends Blip {
05. // insert code here
06. }
Which five methods, inserted independently at line 5, will compile? (Choose five.)
- Apublic int blipvert(int x) { return 0; }
- Bprivate int blipvert(int x) { return 0; }
- Cprivate int blipvert(long x) { return 0; }
- Dprotected long blipvert(int x) { return 0; }
- Eprotected int blipvert(long x) { return 0; }
- Fprotected long blipvert(long x) { return 0; }
- Gprotected long blipvert(int x, int y) { return 0; }
Correct Answer:
ACEFG
private int blipvert(int x) { return 0; } - Cannot reduce the visibility of the inherited method from Blip protected long blipvert(int x) { return 0; } - The return type is incompatible with Blip. blipvert(int)
ACEFG
private int blipvert(int x) { return 0; } - Cannot reduce the visibility of the inherited method from Blip protected long blipvert(int x) { return 0; } - The return type is incompatible with Blip. blipvert(int)
send
light_mode
delete
Question #17
Given:
01. class Super {
02. private int a;
03. protected Super(int a) { this.a = a; }
04. }
11. class Sub extends Super {
12. public Sub(int a) { super(a); }
13. public Sub() { this.a = 5; }
14. }
Which two, independently, will allow Sub to compile? (Choose two.)
01. class Super {
02. private int a;
03. protected Super(int a) { this.a = a; }
04. }
11. class Sub extends Super {
12. public Sub(int a) { super(a); }
13. public Sub() { this.a = 5; }
14. }
Which two, independently, will allow Sub to compile? (Choose two.)
- AChange line 2 to: public int a;
- BChange line 2 to: protected int a;
- CChange line 13 to: public Sub() { this(5); }
- DChange line 13 to: public Sub() { super(5); }
- EChange line 13 to:
Correct Answer:
CD
CD
send
light_mode
delete
Question #18
Which Man class properly represents the relationship "Man has a best friend who is a Dog"?
- Aclass Man extends Dog { }
- Bclass Man implements Dog { }
- Cclass Man { private BestFriend dog; }
- Dclass Man { private Dog bestFriend; }
- Eclass Man { private Dog<bestFriend>; }
- Fclass Man { private BestFriend<dog>; }
Correct Answer:
D
D
send
light_mode
delete
Question #19
Given:
package test;
class Target {
public String name = "hello";
}
What can directly access and change the value of the variable name?
package test;
class Target {
public String name = "hello";
}
What can directly access and change the value of the variable name?
- Aany class
- Bonly the Target class
- Cany class in the test package
- Dany class that extends Target
Correct Answer:
C
C
send
light_mode
delete
Question #20
Given:
11. abstract class Vehicle { public int speed() { return 0; }
12. class Car extends Vehicle { public int speed() { return 60; }
13. class RaceCar extends Car { public int speed() { return 150; } ...
21. RaceCar racer = new RaceCar();
22. Car car = new RaceCar();
23 Vehicle vehicle = new RaceCar();
24 System.out.println(racer.speed() + ", " + car.speed() + ", " + vehicle.speed
());
What is the result?
11. abstract class Vehicle { public int speed() { return 0; }
12. class Car extends Vehicle { public int speed() { return 60; }
13. class RaceCar extends Car { public int speed() { return 150; } ...
21. RaceCar racer = new RaceCar();
22. Car car = new RaceCar();
23 Vehicle vehicle = new RaceCar();
24 System.out.println(racer.speed() + ", " + car.speed() + ", " + vehicle.speed
());
What is the result?
- A0, 0, 0
- B150, 60, 0
- CCompilation fails.
- D150, 150, 150
- EAn exception is thrown at runtime.
Correct Answer:
D
D
send
light_mode
delete
All Pages