1) Abstract class can have abstract and non- abstract methods Interface can have only abstract methods Since Java 8 it can have default and static
Abstract Classes and Abstract Methods An interface is treated like a special class in Java: Uses of interfaces are like for abstract classes:
Interface • A special type of class - a “pure” abstract class: • No data (only static or final) • Defines a set of abstract methods (prototypes)
Abstract classes and Interfaces ? Difference between extends and implements ? Multiple inheritance ? Comparator and Comparable ? Comparing objects
State design pattern; evaluation of functions with JEval; interface specification for a spreadsheet; class diagram hierarchy and modeling for an interconnect
An interface establishes a set of methods that a class will implement • Similar to abstract class but all methods are abstract (and all properties are
CS61B Lecture #9: Interfaces and Abstract Classes Recreation Show that for any polynomial with a leading coefficient of 1 and integral
We will first learn what an abstract class and interface is We will also do a detailed comparison of interfaces and abstract classes followed by a listing