About Question enthuware.ocajp.i.v7.2.845 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

tom1357
Posts: 1
Joined: Wed Mar 04, 2020 3:32 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.845 :

Post by tom1357 »

I'd like to argue that option #1 is a valid choice, based on the wording of the question. The question asks:
"Which of these options can be run with the following command line once compiled?"
It does not specify that the program must complete without exceptions or errors, just that it will compile and run.

/in file main.java
class main {
public void main(String[] args)
{        System.out.println("hello");    }
}

I noticed the incorrect signature for a main() method in option 1, but I knew main() would still compile as a valid class and that program would just have an error at runtime when it found no entry point. I thought that was just a "gotcha" based on the wording of the question, since that option will still compile and can be "run with the following command line."

I understand that #4 is a "more" valid choice, since it runs as intended; I just wanted to point out that #1 seems to satisfy the literal interpretation of the question, and since in a few other questions very literal interpretations are necessary to get a correct answer, there's nothing to distinctly rule it out as I see it. Please correct me if I missed something. Also, I'd like to mention that these tests in general and all the discussions are very helpful, so thanks.

admin
Site Admin
Posts: 10058
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.845 :

Post by admin »

Don't you think, by that logic, you can run anything? It doesn't even have to be a class file!
I understand your point, but in my humble opinion, the meaning is quite clear in the given situation.

Further, if you want to really take the literal meaning, here is another level:
The problem statements says, "Which of these options can be run with ...". The problem statement is not asking merely whether the given command (i.e. java main ) can be executed. The problem statement is asking you whether the code can be run with the given command.
The error produced when you execute the command line is generated by the JVM because it failed to run that class file. In other words, the code in the given option DID NOT get run. Ergo, wrong option :)
If you like our products and services, please help us by posting your review here.

stevefozer
Posts: 1
Joined: Fri May 01, 2020 9:50 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.845 :

Post by stevefozer »

The answer key suggests that this is the correct answer:

//in file main.java
class anothermain{
public static void main(String[] args) {
System.out.println("hello2");
}
}

class main {
public final static void main(String[] args) {
System.out.println("hello");
}
}

With this syntax, yes. However, if it is not just me, I think during the test this option's first two lines were as follows:

//in file main.java
public class anothermain{

which makes this option also incorrect.

admin
Site Admin
Posts: 10058
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.845 :

Post by admin »

In which test? Please post a screenshot.
I see that in our question bank that this option is as you have posted and is correct.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests