go to previous page   go to home page   go to next page highlighting

Answer:

Yes.


Compiling and Running the Program

Organize the program with each class and interface in its own file. Each class can be made public. Put all files into the same subdirectory (folder).

//File: Taxable.java
public interface Taxable
{
}

//File: Goods.java
public class Goods
{
}

//File: Food.java
public class Food extends Goods
{
}

//File: Toy.java
public class Toy extends Goods implements Taxable
{
}

//File: Book.java
public class Book extends Goods implements Taxable
{
}

//File: StoreTester.java
public class StoreTester
{
}

Compile and run in the usual way. The Java compiler looks for and compiles all the files it needs to compile StoreTester.java. The interface, also, compiles into a separate file, Taxable.class

PS C:\Store> javac StoreTester.java
PS C:\Store> java  StoreTester
item: bubble bath price: 1.4
item: bread price: 4.45 1500.0 calories
item: Legos price: 54.45 minimum age: 8
Tax is: 3.267

item: Emma price: 24.95  author: Austin
Tax is: 1.4969999999999999

PS C:\Store> dir

    Directory: C:\Store

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        10/19/2024   3:24 PM            982 Book.class
-a----        10/19/2024   3:24 PM            364 Book.java
-a----        10/19/2024   3:24 PM            819 Food.class
-a----        10/19/2024   3:21 PM            263 Food.java
-a----        10/19/2024   3:24 PM            864 Goods.class
-a----        10/19/2024   3:21 PM            288 Goods.java
-a----        10/19/2024   3:24 PM           1373 StoreTester.class
-a----        10/19/2024   3:22 PM            553 StoreTester.java
-a----        10/19/2024   3:24 PM            179 Taxable.class
-a----        10/19/2024   3:21 PM             85 Taxable.java
-a----        10/19/2024   3:24 PM            937 Toy.class
-a----        10/19/2024   3:22 PM            367 Toy.java

\
PS C:\Store>


QUESTION 16:

Could the project be run in BlueJ?


go to previous page   go to home page   go to next page