What is the result?


And given the commands:
javac Test.Java Java Test Hello
What is the result?
A. Success
B. Failure
C. Compilation fails.
D. An exception is thrown at runtime

Download Printable PDF. VALID exam to help you PASS.

5 thoughts on “What is the result?

  1. B
    public static void main(String[] args) {
    if(args[0].equals(“Hello”) ?false : true){ //it is true so print else “Failure”

  2. Answer B:

    A tricky smart question. The ternary expression as a whole is in fact a boolean expression for the if statement. So in case the args[0].equals(“Hello”) is true, then the whole if statement will be “if(false)”, therefore, the “Failure will be printed.

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.