Hey guys, I'm learning my first Java Cert! Hurah! Sorry, I do not want to sound so insulting, but I can not help it :) Anywho, trying to understand the following question and answer. I do not understand., I do not really use this command line (mainly NetBeans, and I get to know Eclipse). Any pointers are welcome.
PURPOSE: 7.2: Using the example and command line examples, determine the expected runtime behavior. 10)
Given:
1. class x {
2. public static void main(String [] args) {
3. String p = System.getProperty("x");
4. if(p.equals(args[1]))
5. System.out.println("found");
6. }
7. }
What command line call will print the result?
a) java -Dx=y x y z
b) java -Px=y x y z
c) java -Dx=y x x y z (*)
d) java -Px=y x x y z
e) java x x y z -Dx=y
f) java x x y z -Px=y
// So, the answer is C
REFERENCE:
API for java command
Option C is correct. -D sets the property, and args [1] the second argument (whose value is y)
., [1] ? , "p" String {y x x y z}?