This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Which command-line invocation will produce the output found?
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
Option C is correct. -D sets a property and args is the second argument (whose value is y)
This is what I understand:
1. The program is assigning the system property of "x" to String 2. When the runtime environment is invoked with c)java -Dx=y x x y z , it is setting the system property of "x" to "y". Then the program x is invoked. Next, args get the value of "x". Then, args gets the value of "y". This value of "y" is equal to the system value of "x", which is "y". Hence, "found" is printed.