Java Magazine, Mar/Apr 2018
ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 97 fix this Answers Answer 1 The correct answers are options A and E The form of Javas main entry point has been refined a bit over the years of the languages history For example at one time the method was not required to be public However section 1214 of the Java 8 version of the Java Language Specification says the following The method main must be declared public static and void It must specify a formal parameter whose declared type is array of String Given these requirements its clear that option A must be correct and options B and C must be incorrect However options D and E are yet to be resolved The specification demands that the formal parameters type must be array of String If the term formal parameter is unfamiliar it simply refers to the argument listed in the methods declaration the term distinguishes that argument from the actual parameter which is the value passed in by an invocation Clearly the form presented in option D defines an array of String and it is actually the usual form But option D demands this argument must be exactly as shown Its reasonable to question this because the name of the formal parameter args in this case isnt usually syntactically critical In fact it turns out that A running Java program is unlikely to be slower than a program in a compiled language that uses the same data structures and algorithms the ellipsis form which defines a variable length argument list really causes the formal parameter to be of array type This means that option E while unconventional with respect to
You must have JavaScript enabled to view digital editions.