Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Easy

Question 29

Given code of Test.java file:


Which of the following options is correct?

  • A

    To print C on to the console, execute below commands:

    javac Test.java

    java C

  • B Test.java file will compile successfully but expected output is not possible
  • C

    To print C on to the console, execute below commands:

    javac Test.java

    java Test

  • D Test.java file is not a valid java file as it doesn't contain code for class Test
  • E

    To print C on to the console, execute below commands:

    javac C.java

    java C

Reveal correct answer

Correct answer: A

Explanation

Test.java is a valid java file. As none of the classes in Test.java file are public, hence file name can use any valid Java identifier.

As file name is Test.java, hence to compile the code below command is used:

javac Test.java


Execution of above command creates 4 class files: A.class, B.class, C.class & D.class.

To print C on to the console, class C must be executed. To execute C class, command is:

java C

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need