§Enables you to “program in thegeneral” rather than “program in the specific.”
§Polymorphism enables you to write programs that process objects that share the same superclass as if they’re all objects of the superclass; this can simplify programming.
}With polymorphism, we can design andimplement systems that are easily extensible
§New classes can be added with little or no modification to the general portions of the program, as long as the new classes are part of the inheritance hierarchy that the program processes generically.
§The only parts of a program that must be altered to accommodate new classes are those that require direct knowledge of the new classes that we add to the hierarchy.
}Once a class implements an interface, all objects of that class have an is-a relationship with the interface type, and all objects of the class are guaranteed to provide the functionality described by the interface.
}This is true of all subclasses of that class as well.
}Interfaces are particularly useful for assigning common functionality to possibly unrelated classes.
§Allows objects of unrelated classes to be processed polymorphically—objects of classes that implement the same interface can respond to all of the interface method calls.
}An interface describes a set of methods that can be called on an object, but does not provide concrete implementations for all the methods.
}You can declare classes that implement(i.e., provide concrete implementations for the methods of) one or more interfaces.
}Each interface method must be declared inall the classes that explicitly implement the interface.
§Enables you to “program in thegeneral” rather than “program in the specific.”§Polymorphism enables you to writeprograms that process objects that share the same superclass as if they’re allobjects of the superclass; this can simplify programming.
}With polymorphism, we can design andimplement systems that are easily extensible§New classes can be added withlittle or no modification to the general portions of the program, as long asthe new classes are part of the inheritance hierarchy that the programprocesses generically. §The only parts of a program thatmust be altered to accommodate new classes are those that require directknowledge of the new classes that we add to the hierarchy.
}Once a class implements an interface, allobjects of that class have an is-arelationship with the interface type, andall objects of the class are guaranteed to provide the functionality describedby the interface. }This is true of all subclasses of thatclass as well.}Interfaces are particularly useful forassigning common functionality to possibly unrelated classes. §Allows objects of unrelated classesto be processed polymorphically—objects of classes that implement thesame interface can respond to all of the interface method calls.
}An interface describes a set of methodsthat can be called on an object, but does not provide concrete implementationsfor all the methods. }You can declare classes that implement(i.e., provide concrete implementations for the methods of) one or moreinterfaces. }Each interface method must be declared inall the classes that explicitly implement the interface.
§Enables you to “program in thegeneral” rather than “program in the specific.”§Polymorphism enables you to writeprograms that process objects that share the same superclass as if they’re allobjects of the superclass; this can simplify programming.
}With polymorphism, we can design andimplement systems that are easily extensible§New classes can be added withlittle or no modification to the general portions of the program, as long asthe new classes are part of the inheritance hierarchy that the programprocesses generically. §The only parts of a program thatmust be altered to accommodate new classes are those that require directknowledge of the new classes that we add to the hierarchy.
}Once a class implements an interface, allobjects of that class have an is-arelationship with the interface type, andall objects of the class are guaranteed to provide the functionality describedby the interface. }This is true of all subclasses of thatclass as well.}Interfaces are particularly useful forassigning common functionality to possibly unrelated classes. §Allows objects of unrelated classesto be processed polymorphically—objects of classes that implement thesame interface can respond to all of the interface method calls.
}An interface describes a set of methodsthat can be called on an object, but does not provide concrete implementationsfor all the methods. }You can declare classes that implement(i.e., provide concrete implementations for the methods of) one or moreinterfaces. }Each interface method must be declared inall the classes that explicitly implement the interface.