Polymorphic Behavior


Final Classes & Methods

Sometimes you want to prevent classes from being extended or individual methods of a particular class from being overridden. The keyword final is used for these purposes. When used to declare a class it prevents that class from being extended. When used to declare a method it prevents the method from being overridden in a derived class.

You cannot use the keyword final in combination with the keyword abstract for obvious reasons.

Quick Review

Use the final keyword to stop the inheritance mechanism or prevent base class methods from being overridden in derived classes.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net