http://https://www.lead1pass.com/Oracle/1Z0-851-practice-exam-dumps.html (290 Q&As Dumps, 30%OFF Special Discount: 30free )
NEW QUESTION NO: 26
Which three statements are true? (Choose three.)
A. A private static method can be called only within other static methods in class X.
B. A public static method in class X can be called by a subclass of X without explicitly referencing the class X.
C. A method with the same signature as a private final method in class X can be implemented in a subclass of X.
D. A final method in class X can be abstract if and only if X is abstract.
E. A non-static public final method in class X can be overridden in any subclass of X.
F. A protected method in class X can be overridden by any subclass of X.
G. A protected method in class X can be overridden by a subclass of X only if the subclass is in the same package as X.
Answer: B,C,F
NEW QUESTION NO: 27
Given:
public class Donkey {
public static void main(String[] args) {
boolean assertsOn = false;
assert (assertsOn) : assertsOn = true;
if(assertsOn) {
System.out.println("assert is on");
}
}
}
If class Donkey is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results?
A. no output assert is on
B. no output
C. assert is on
D. no output
An AssertionError is thrown.
E. assert is on
An AssertionError is thrown.
Answer: D
NEW QUESTION NO: 28
Click the Exhibit button.
1. public class GoTest {
2. public static void main(String[] args) {
3. Sente a = new Sente(); a.go();
4. Goban b = new Goban(); b.go();
5. Stone c = new Stone(); c.go();
6. }
7. }
8.
9. class Sente implements Go {
10. public void go(){
11. System.out.println("go in Sente");
12. }
13. }
14.
15. class Goban extends Sente {
16. public void go(){
17. System.out.println("go in Goban");
18. }
19.
20. }
21. class Stone extends Goban implements Go{
22. }
23.
24. interface Go { public void go(); }
What is the result?
A. go in Goban go in Sente go in Sente
B. go in Goban go in Goban go in Sente
C. go in Sente go in Sente go in Goban
D. Compilation fails because of an error in line 17.
E. go in Sente go in Goban go in Goban
Answer: E
NEW QUESTION NO: 29
Given:
33. Date d = new Date(0);
34. String ds = "December 15, 2004";
35. // insert code here
36. try {
37. d = df.parse(ds);
38. }
39. catch(ParseException e) {
40. System.out.println("Unable to parse " + ds);
41. }
42. // insert code here too
What creates the appropriate DateFormat object and adds a day to the Date object?
A. 35. DateFormat df = DateFormat.getDateFormat();
42. d.setTime( (60 * 60 * 24) + d.getTime());
B. 35. DateFormat df = DateFormat.getDateInstance();
42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());
C. 35. DateFormat df = DateFormat.getDateInstance();
42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());
D. 35. DateFormat df = DateFormat.getDateFormat();
42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());
Answer: C
NEW QUESTION NO: 30
Given:
public class PingPong implements Runnable {
synchronized void hit(long n) {
for (int i = 1; i < 3; i++)
System.out.print(n + "-" + i + " ");
}
public static void main(String[] args) {
new Thread(new PingPong()).start();
new Thread(new PingPong()).start();
}
public void run() {
hit(Thread.currentThread().getId());
}
}
Which two statements are true? (Choose two.)
A. The output could be 7-1 7-2 8-1 6-1
B. The output could be 8-1 8-2 7-1 7-2
C. The output could be 8-1 7-2 8-2 7-1
D. The output could be 8-1 7-1 7-2 8-2
Answer: B,D
NEW QUESTION NO: 31
Given:
public class Person {
private name;
public Person(String name) {
this.name = name;
}
public int hashCode() {
return 420;
}
}
Which statement is true?
A. The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.
B. The time to find the value from HashMap with a Person key depends on the size of the map.
C. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person.
D. Inserting a second Person object into a HashSet will cause the first Person object to be removed as a duplicate.
Answer: B
NEW QUESTION NO: 32
Given:
public class Base {
public static final String FOO = "foo";
public static void main(String[] args) {
Base b = new Base();
Sub s = new Sub();
System.out.print(Base.FOO);
System.out.print(Sub.FOO);
System.out.print(b.FOO);
System.out.print(s.FOO);
System.out.print(((Base) s).FOO);
}
}
class Sub extends Base {
public static final String FOO = "bar";
}
What is the result?
A. foobarfoofoofoo
B. foofoofoofoofoo
C. foofoofoobarfoo
D. barbarbarbarbar
E. foobarfoobarbar
F. foofoofoobarbar
G. foobarfoobarfoo
Answer: G
NEW QUESTION NO: 33
Given:
int x = 0;
int y = 10;
do {
y--;
++x;
} while (x < 5);
System.out.print(x + "," + y);
What is the result?
A. 6,6
B. 5,6
C. 5,5
D. 6,5
Answer: C
NEW QUESTION NO: 34
DRAG DROP
Select and Place:

Answer:

NEW QUESTION NO: 35
Given:
1. public class Plant {
2. private String name;
3.
4. public Plant(String name) {
5. this.name = name;
6. }
7.
8. public String getName() {
9. return name;
10. }
11.}
1. public class Tree extends Plant {
2. public void growFruit() {
3. }
4.
5. public void dropLeaves() {
6. }
7. }
Which statement is true?
A. The code will compile if public Plant() { Tree(); } is added to the Plant class.
B. The code will compile if public Plant() { Plant("fern"); } is added to the Plant class.
C. The code will compile without changes.
D. The code will compile if public Tree() { Plant(); } is added to the Tree class.
E. The code will compile if public Plant() { this("fern"); } is added to the Plant class.
Answer: E
NEW QUESTION NO: 36
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();
methodA();
What is the result?
A. ClassC is displayed.
B. An exception is thrown at runtime.
C. Compilation fails.
D. The code runs with no output.
Answer: B