enthuware.ocajp.i.v7.2.1230 given answer is incorrect
Posted: Sun Dec 27, 2015 8:36 pm
The correct answer is the first one: Hello.
When this code is run, and when the so-called main method is reached, it will print out Hello.
Then it will return 10 as a a long.
It is legal for a method to both print to console and then return a value, so long as the print happens first.
This particular method is horribly named, and should never exist in real code. It is in the legal-but-horribly-wrong category, like naming methods identically to constructors.
As others have noted, the main method is really not.
Thus, Hello is a valid answer to the question as written.
Here you need to decide what it is you really want to ask about, then write a proper question. Several different topics could be tested here: method signatures, return values, unreachable code.
When this code is run, and when the so-called main method is reached, it will print out Hello.
Then it will return 10 as a a long.
It is legal for a method to both print to console and then return a value, so long as the print happens first.
This particular method is horribly named, and should never exist in real code. It is in the legal-but-horribly-wrong category, like naming methods identically to constructors.
As others have noted, the main method is really not.
Thus, Hello is a valid answer to the question as written.
Here you need to decide what it is you really want to ask about, then write a proper question. Several different topics could be tested here: method signatures, return values, unreachable code.