Valid 1Z0-851 Dumps shared by Examslabs for Helping Passing 1Z0-851 Exam! Examslabs now offer the newest 1Z0-851
exam dumps, the Examslabs 1Z0-851 exam questions have been updated and answers have been corrected get the newest Examslabs
1Z0-851 dumps with Test Engine here:
https://www.examslabs.com/Oracle/OCJP/best-1Z0-851-exam-dumps.html (290 Q&As Dumps, 30%OFF Special Discount: bmzblwH7 )
NEW QUESTION NO: 8
Given:01. interface A { public void aMethod(); }
02. interface B { public void bMethod(); }
03. interface C extends A,B { public void cMethod(); }
04. class D implements B {
05. public void bMethod(){}
06. }
07. class E extends D implements C {
08. public void aMethod(){}
09. public void bMethod(){}
10. public void cMethod(){}
11. }
What is the result?
A. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 3.
D. Compilation fails because of an error in line 9.
E. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.
F. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.
Answer: E
NEW QUESTION NO: 9
Given a valid DateFormat object named df, and
16. Date d = new Date(0L);
17. String ds = "December 15, 2004";
18. //insert code here
What updates d's value with the date represented by ds?
A. try {
d = df.parse(ds);
} catch(ParseException e) { };
B. d = df.parse(ds);
C. try {
d = df.getDate(ds);
} catch(ParseException e) { };
D. d = df.getDate(ds);
Answer: A
NEW QUESTION NO: 10
Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object? (Choose two.)
A. When you plan to reuse the StringBuffer to build more than one string.
B. When sharing a StringBuffer among multiple threads.
C. When using versions of Java technology earlier than 5.0.
D. When using the java.io class StringBufferInputStream.
Answer: B,C
NEW QUESTION NO: 11
DRAG DROP
Select and Place:

Answer:

NEW QUESTION NO: 12
Given:
public class ItemTest {
private final int id;
public ItemTest(int id) {
this.id = id;
}
public void updateId(int newId) {
id = newId;
}
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. The attribute id in the ItemTest object remains unchanged.
D. The attribute id in the ItemTest object is modified to the new value.
E. A new ItemTest object is created with the preferred value in the id attribute.
Answer: A
Explanation/Reference:
Explanation:
The final field ItemTest.id cannot be assigned
NEW QUESTION NO: 13
Given:
11. public static void main(String[] args) {
12. Object obj = new int[] { 1, 2, 3 };
13. int[] someArray = (int[])obj;
14. for (int i : someArray) System.out.print(i + " ");
15. }
What is the result?
A. Compilation fails because of an error in line 12.
B. A ClassCastException is thrown at runtime.
C. 1 2 3
D. Compilation fails because of an error in line 13.
E. Compilation fails because of an error in line 14.
Answer: C
NEW QUESTION NO: 14
DRAG DROP
Place the correct description of the compiler output on the code fragments to be inserted at lines 4 and 5.
The same compiler output may be used more than once.
01. import java.util.*;
02. public class X {
03. public static void main(String[] args) {
04. // insert code here
05. // insert code here
06. }
07. public static void foo(List<Object> list) { }
08. }
Select and Place:

Answer:

NEW QUESTION NO: 15
Given:
34. HashMap props = new HashMap();
35. props.put("key45", "some value");
36. props.put("key12", "some other value");
37. props.put("key39", "yet another value");
38. Set s = props.keySet();
39. //insert code here
What, inserted at line 39, will sort the keys in the props HashMap?
A. s = new SortedSet(s);
B. Arrays.sort(s);
C. Collections.sort(s);
D. s = new TreeSet(s);
Answer: D
NEW QUESTION NO: 16
Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket. Which two code fragments represent these relationships? (Choose two.)
A. class Gadget {
}
class Widget extends Gadget {
Sprocket s1;
Spring s2;
}
B. class Widget {
Sprocket s;
}
class Gadget extends Widget {
Spring s;
}
C. class Widget {
Sprocket s1;
Spring s2;
}
class Gadget extends Widget {
}
D. class Gadget {
Spring s;
}
class Widget extends Gadget {
Sprocket s;
}
E. class Gadget {
Spring s1;
Sprocket s2;
}
class Widget extends Gadget {
}
F. class Widget {
}
class Gadget extends Widget {
Spring s1;
Sprocket s2;
}
Answer: B,C
NEW QUESTION NO: 17
A company has a business application that provides its users with many different reports: receivables reports, payables reports, revenue projects, and so on. The company has just purchased some new, state- of-the-art, wireless printers, and a programmer has been assigned the task of enhancing all of the reports to use not only the company's old printers, but the new wireless printers as well. When the programmer starts looking into the application, the programmer discovers that because of the design of the application, it is necessary to make changes to each report to support the new printers. Which two design concepts most likely explain this situation? (Choose two.)
A. Loose coupling
B. Object immutability
C. Tight coupling
D. High cohesion
E. Low cohesion
F. Inheritance
Answer: C,E
NEW QUESTION NO: 18
Given:
33. try {
34. //some code here
35. } catch (NullPointerException e1) {
36. System.out.print("a");
37. } catch (Exception e2) {
38. System.out.print("b");
39. } finally {
40. System.out.print("c");
41. }
If some sort of exception is thrown at line 34, which output is possible?
A. abc
B. c
C. ac
D. a
E. b
Answer: C