Exercise_12_2 - 1 Exercise 12-2 Work with an interface In this exercise youll create two interfaces Then youll implement them and use them Review the

Exercise_12_2 - 1 Exercise 12-2 Work with an interface In...

This preview shows page 1 out of 1 page.

1 Exercise 12-2 Work with an interface In this exercise, you’ll create two interfaces. Then, you’ll implement them and use them. Review the code 1 Open the project named ch12_ex2_ProductLister. 2 Review the code. Note that the Main class contains three constants for the width of the three columns of data. 3 Run the application to make sure that it works correctly. Create an interface and implement it 1. In the murach.db package, create an interface named IProductDB. This interface should specify this abstract method: public abstract Product get(String productCode); 2. Modify the ProductDB class so it implements the IProductDB interface. 3. In the Main class, modify the code so it works with the new ProductDB class. This code should create an instance of the IProductDB interface like this: IProductDB db = new ProductDB(); This shows that the ProductDB class implements the IProductDB interface. 4. Run the application to make sure it works correctly. Modify another class so it implements the interface 5. In the ProductDB2 class, modify the code so it implements the IProductDB
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes