Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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: 40912
840
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: 40912
840
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!
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! 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