Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Nested Type Declarations > Programming Exercise

Programming Exercise

8.1Create a new program with a nested class named PrintFunc that extends class Print from Exercise 7.2, p. 350. In addition to just printing the value, class PrintFunc should first apply a Function object on the value. The class PrintFunc should have a constructor that takes an instance of Function type as a parameter. The evaluate() method of the class PrintFunc should use the Function object on its argument. The evaluate() method should print and return the result. The evaluate() method in superclass Print should be used to print the value.

The program should behave like the one in Exercise 7.2, p. 350, but this time use the nested class PrintFunc instead of class Print.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint