• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Errata OCP Java SE 11 Programmer I Study Guide - Single-file Source-code Command

 
Greenhorn
Posts: 13
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Errata OCP Java SE 11 Programmer I Study Guide, in page 13, in table 1.1, It is written that Single-file source-code command is for programs with one class. But it should be written as `For programs with one file`.

It will be better in this way. Because there may be more than one class in a java file.
 
author & internet detective
Posts: 41762
885
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
I agree. I've added this to errata. I actually had the same rror on page 12 in the text. That was added to the errata in January.

(This error from me not knowing how this feature worked for a multi class file until after the book printed. I like the feature but use it for simple programs in real life)
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Jeanne, Ilkay,

The java MyClasses.java option ONLY works for a SINGLE class in the file MyClasses.java.

It is the FIRST class that is declared.

If you have 2 or more classes, they are ignored.

You cannot extend another class in the file MyClasses.java.

If the first declared class extends another class in the same file MyClasses.java, the command will fail.

Hope this helps and thanks,

Bassam
 
Jeanne Boyarsky
author & internet detective
Posts: 41762
885
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bassam,
Welcome to CodeRanch! While I agree the main method must be in the first class, it can reference other classes in the file. The following works:

 
Bassam Gemayel
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brilliant! Did not even think about trying this! :-)

Thus, you CAN have multiple classes in the file and they are compiled.

Thank you, Jeanne!

PS.: You and Scott created a gem, I learned faster and more accurately reading your book than I ever did reading any other Java material, kudos!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic