What is the result?

Given:

What is the result?
A. String main 1
B. An exception is thrown at runtime
C. String main 1 2 3
D. String main 123

Download Printable PDF. VALID exam to help you PASS.

6 thoughts on “What is the result?

  1. C:

    # javac MainTest.java
    # java MainTest “1 2 3”
    String main 1 2 3
    ——————————————-
    But if without double quotes:
    # javac MainTest.java
    # java MainTest 1 2 3
    String main 1

  2. Answer C.

    The argument “1 2 3” is basically a one String value. So args[0] equals the whole String value.

    11

Leave a Reply

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