Given:
What is the result?
Given:
What is the result?
The code uses a variable argument (varargs) in the greet method, which allows for zero or more arguments to be passed. When the greet method is called with no arguments, the args array is empty. The for loop iterates over the args array, but since it is empty, nothing is printed in the loop. The static method greet can be called on a null reference without causing a NullPointerException because c is used to access the static method. Therefore, the program will print 'Hello ' followed by no additional output, making the result 'Hello '.
c.greet() with empty argument produce args = String[0] loop is not executed Main c = null; c.greet(); The access to static members is allowed through instances of the class that defines them. The value of the instance doesn't matter. it could be null.
Tested: D.
D is correct,due to the error in line 7
Tested A
A is correct, if line 7 (<span> is not considered) because String ... args generate a empty string by default.so if you no send arguments is an empty array. foreach dont print anything
D is correct,due to the error in line 7. Correct line 7 then the answer becomes A.