Page 1 of 1

About Question enthuware.ocpjp.i.v11.2.1258 :

Posted: Mon Nov 30, 2020 2:21 pm
by lazyf1sh
Hi,

it seems there is a mistake. Correct option is "None of the above.", because it is throws the exception.

Code: Select all

public class MyClass
{
	public static void main(String[] args)
	{
		System.out.println(args[0]);
	}
}
java version:

Code: Select all

C:\1\projects\sandbox-java\sandbox-java11-cmdline>java -version
java version "11.0.9" 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)
Without extension.

Code: Select all

C:\1\projects\sandbox-java\sandbox-java11-cmdline>java MyClass hi
Error: Could not find or load main class MyClass
Caused by: java.lang.ClassNotFoundException: MyClass
Also tried to rename from MyClass.java to MyClass - it didn't help. Java source class must have .java extension and it must be specifed in the command.


Filename extension is required when running single file source code.

Code: Select all

C:\1\projects\sandbox-java\sandbox-java11-cmdline>java MyClass.java hi
hi
Thanks.

Re: About Question enthuware.ocpjp.i.v11.2.1258 :

Posted: Tue Dec 01, 2020 9:45 am
by admin
You are right, the problem statement has been updated to include the words, "compiled and then run" instead of just "run".
BTW, Single File source code execution is not on 819 exam any more so, you have to assume that the code is compiled and then run unless explicitly said otherwise.

thank you for your feedback!