Language Elements


  • Single inheritance rooted in common class Object

  • Subclassing builds new types
    public class ExitableFrame
    extends java.awt.Frame { ... }

  • Support for mix-in "inheritance" via Interfaces enhances opportunities for reuse

  • Strongly type checked
    • Most type checking performed statically
    • Assignment type compatibility checked dynamically (if necessary)

  • Access protection for classes, fields and methods

Detailed Description:

"We also have this multiple interface inheritance. An interface is called a mix-in. It defines the pure, outer interface of an object. It might represent a type as opposed to an implementation which is represented by a class. With interfaces, you can do multiple inheritance. So we could define that a specific class inherits from a single class and inherits from multiple interfaces.

Java is strongly type checked. Unlike languages such as Smalltalk, Java compiler does type checking during compile time. Each variable must have a type. Every cell and memory has only one type associated with it, and it must be statically determined at compile time. It is considered a compiler error if one cannot determine the type. Also, as part of the verification process, this same check is done when classes are loaded in. Also, assignment checking is done during run time.

Finally, Java has access protection. We saw that earlier in our source code examples. It has public, private, protected, and also a new one we'll discuss in more detail called package level protection for classes, fields (variables), and methods."