Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Sybex OCP 11 Programmer I. Chapter 1 review question 2

 
Ranch Hand
Posts: 53
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jeanne and Scott
I believe that one of the answers in the review questions for the first chapter of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide is vague.

Which of the following are true? (Choose all that apply.)


Here two options are present

java accepts the name of the class as a parameter.
java accepts the filename of the .class file as a parameter.



And the second one considered incorrect. I believe it is not clear that the file name means the full name with extension. I decided that this is about real name avoiding extension and as java runs bytecode file answered it. I believe it would have been more clear to specify specifically that here filename considered to be the one with extension.
 
Marshal
Posts: 74374
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please supply more information about the question for those of us who don't have the book.
You can write java MyClass or java MyFile.java so I think you are correct. I presume you have checked here for the errata.
 
Oksana Cherniavskaia
Ranch Hand
Posts: 53
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it is not an error, I think, but the wording is vague and depends on an assumption that filename consists of actual name and extension. Unfortunately, the all information on this question as it is true/false kind of question is short.


Which of the following are true? (Choose all that apply.)
javac compiles a .class file into a .java file.
javac compiles a .java file into a .bytecode file.
javac compiles a .java file into a .class file.
java accepts the name of the class as a parameter.
java accepts the filename of the .bytecode file as a parameter.
java accepts the filename of the .class file as a parameter.



Excerpt From: Boyarsky, Jeanne. “OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide”.

And the correct answers and comments from author

C, D. Java puts source code in .java files and bytecode in .class files. It does not use a .bytecode file. When running a Java program, you pass just the name of the class without the .class extension.


Excerpt From: Boyarsky, Jeanne. “OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide”.

It just yes, you do pass name without extension, but I consider that I am passing the name of the file without extention.
 
Campbell Ritchie
Marshal
Posts: 74374
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

. . . I consider that I am passing the name of the file without extention.

In which case what will happen if you have this sort of XYZ.java file?You cannot pass the name of a file minus its extension here. There is no requirement that the name of a class match the name of the file. There is no requirement for a type to have the same name as its enclosing file. We do know that most compilers are allowed to insist that public classes have the same name as their enclosing files, but I haven't shown you any public classes. You can argue that this question is a bit vague, but it seems obvious to me that the correct answer is CD.
 
Enthuware Software Support
Posts: 4584
45
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option "java accepts the filename of the .class file as a parameter." is simply incorrect. java doesn't accept filename at all (with or without extension is out of question) (Not considering single file source code). To be precise, java doesn't accept classname either. It accepts Fully Qualified Class Name. i.e. with package name com.abc.MyClass or whatever.

 
author & internet detective
Posts: 40797
829
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
This is chapter 1. They don't know what a package is yet .

Oksana,
We considered the file name to be the full filename. So Oksana.class.
 
Oksana Cherniavskaia
Ranch Hand
Posts: 53
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne and Paul, thanks a lot for the reply. With the fully qualified class name it actually easier to understand.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic