• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

chapter 1 practice question 23 (Java OCA 8 Programmer I Study Guide, Sybex)

 
Claudiu Stroe
Greenhorn
Posts: 29
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the exam for first chapter at question 23 the answer is wrong (Answer :C,D ).
It must be only C , javac compiles a .java file into a .class file.
Option D is incorrect. Java doesn't take name of the class as parameter. The args[0] will be equal with the first String after the name of the class.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claudiu Stroe wrote:Option D is incorrect. Java doesn't take name of the class as parameter. The args[0] will be equal with the first String after the name of the class.

The study guide is spot-on! Both answers C and D are correct.

Probably the root cause of your thought/assumption is a misunderstanding of parameters and program arguments. You can pass several parameters to the java command. Some of them will be interpreted as options, one will be the class name and some will be passed to the program as arguments. Let's have a look at the java commandSo the first parameter which is not an option, is the name of the class to be called. Other parameters after this will be passed to the class as program arguments.

So options D, E, and F are nothing more than textual descriptions of these possible invocations and you have to select the correct oneAnd obviously option D is the correct one

Hope it helps!
Kind regards,
Roel
 
Claudiu Stroe
Greenhorn
Posts: 29
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Roel.
Your explication is really helpful, like always.

I don't know why I complecate simple questions
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Claudiu Stroe wrote:I don't know why I complecate simple questions

On the actual exam the number of correct answers you must select is mentioned, so you probably would have selected the correct answers if you knew you had to select 2 answers (because all four other options are more wrong than option D).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic