nerdexam
Oracle

1Z0-851 · Question #84

Given: 12. public class Commander { 13. public static void main(String[] args) { 14. String myProp = / insert code here / 15. System.out.println(myProp); 16. } 17. } and the command line: java…

The correct answer is D. System.getProperty("prop.custom"); E. System.getProperties().getProperty("prop.custom"). See the full explanation below for the reasoning.

Question

Given: 12. public class Commander { 13. public static void main(String[] args) { 14. String myProp = /* insert code here */ 15. System.out.println(myProp); 16. } 17. } and the command line: java -Dprop.custom=gobstopper Commander Which two, placed on line 13, will produce the output gobstopper? (Choose two.)

Options

  • ASystem.load("prop.custom");
  • BSystem.getenv("prop.custom");
  • CSystem.property("prop.custom");
  • DSystem.getProperty("prop.custom");
  • ESystem.getProperties().getProperty("prop.custom");

How the community answered

(41 responses)
  • A
    2% (1)
  • B
    12% (5)
  • C
    5% (2)
  • D
    80% (33)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice