Given:
1.
public class Plant {
2.
private String name;
3.
public Plant(String name) { this.name = name; }
4.
public String getName() { return name; }
5.
}
1.
public class Tree extends Plant {
2.
public void growFruit() { }
3.
public void dropLeaves() { }
4.
}
Which statement is true?
A. The code will compile without changes.Given the following directory structure:
bigProject |--source | |--Utils.java | |--classes |-- And the following command line invocation: javac -d classes source/Utils.java
Assume the current directory is bigProject, what is the result?
A. If the compile is successful, Utils.class is added to the source directory.Given:
11.
public static void main(String[] args) {
12.
Integer i = new Integer(1) + new Integer(2);
13.
switch(i) {
14.
case 3: System.out.println("three"); break;
15.
default: System.out.println("other"); break;
16.
}
17.
}
What is the result?
A. threeGiven:
3.
interface Animal { void makeNoise(); }
4.
class Horse implements Animal {
5.
Long weight = 1200L;
6.
public void makeNoise() { System.out.println("whinny"); }
7.
}
8.
public class Icelandic extends Horse {
9.
public void makeNoise() { System.out.println("vinny"); }
10.
public static void main(String[] args) {
11.
Icelandic i1 = new Icelandic();
12.
Icelandic i2 = new Icelandic();
13.
Icelandic i3 = new Icelandic();
14.
i3 = i1; i1 = i2; i2 = null; i3 = i1;
15.
}
16.
}
When line 15 is reached, how many objects are eligible for the garbage collector?
B. 1Given:
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?
A. s 14Given:
11.
static void test() throws Error {
12.
if (true) throw new AssertionError();
13.
System.out.print("test ");
14.
}
15.
public static void main(String[] args) {
16.
try { test(); }
17.
catch (Exception ex) { System.out.print("exception "); }
18.
System.out.print("end ");
19.
}
What is the result?
A. endGiven:
5.
class Building { }
6.
public class Barn extends Building {
7.
public static void main(String[] args) {
8.
Building build1 = new Building();
9.
Barn barn1 = new Barn();
10.
Barn barn2 = (Barn) build1;
11.
Object obj1 = (Object) build1;
12.
String str1 = (String) build1;
13.
Building build2 = (Building) barn1;
14.
}
15.
}
Which is true?
A. If line 10 is removed, the compilation succeeds.Given:
1.
public class Score implements Comparable
2.
private int wins, losses;
3.
public Score(int w, int l) { wins = w; losses = l; }
4.
public int getWins() { return wins; }
5.
public int getLosses() { return losses; }
6.
public String toString() {
7.
return "<" + wins + "," + losses + ">";
8.
}
9.
// insert code here
10.
}
Which method will complete this class?
A. public int compareTo(Object o){/*more code here*/}Given:
5 class Atom {
6 Atom() { System.out.print("atom "); }
7 }
8 class Rock extends Atom {
9 Rock(String type) { System.out.print(type); } 10 }
11 public class Mountain extends Rock {
12 Mountain() {
13. super("granite ");
14 new Rock("granite ");
15 }
16 public static void main(String[] a) { new Mountain(); } 17 }
What is the result?
A. Compilation fails.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?
A. s 14Nowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Oracle exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your 1Z0-851 exam preparations and Oracle certification application, do not hesitate to visit our Vcedump.com to find your solutions here.