Untitled

Cards (10)

  • Forms of inheritance
    • Interface
    • Implementation
  • Interface in Java
    An abstract type used to specify the behavior of a class
  • Interface in Java
    A blueprint of a class
  • Interface in Java
    • Contains static constants and abstract methods
  • Interface in Java
    • Methods declared in an interface are by default abstract (only method signature, no body)
  • Interface
    Specifies what a class must do and not how. It is the blueprint of the class
  • Interface
    About capabilities like a Player may be an interface and any class implementing Player must be able to (or must implement) move(). So it specifies a set of methods that the class has to implement
  • If a class implements an interface and does not provide method bodies for all functions specified in the interface, then the class must be declared abstract
  • Interfaces are used to implement abstraction. So the question arises why use interfaces when we have abstract classes?
  • The major differences between a class and an interface are:
    1. In class, you can instantiate variables and create and object.
    2. Class can contain concrete(with implementation) methods.
    3. The access specifiers with classes are private, protected, and public.

    1. In an interface, you cant instantiate variables and create an object.
    2. The interface cannot contain concrete(with implementation) methods.
    3. In interface only one specifier is used-Public.