Tuesday, June 17, 2014

Interfaces - cribnotes for the interview exam

Reference type - you can pass interface around

cool to use in jsf and annotation - jboss will wire your implementation to an interface usign a annotation. Weld baby

Only constants, method sigs, default methods, static ,methods, nested types

interface can be extended by another interface

example from orACLE

Defining an interface is similar to creating a new class:
public interface OperateCar {

   // constant declarations, if any

   // method signatures
   
   // An enum with values RIGHT, LEFT
   int turn(Direction direction,
            double radius,
            double startSpeed,
            double endSpeed);
   int changeLanes(Direction direction,
                   double startSpeed,
                   double endSpeed);
   int signalTurn(Direction direction,
                  boolean signalOn);
   int getRadarFront(double distanceToCar,
                     double speedOfCar);
   int getRadarRear(double distanceToCar,
                    double speedOfCar);
         ......
   // more method signatures
}
Note that the method signatures have no braces and are terminated with a semicolon.


COMMON USAGE
callbacks
events same thing
clone
serialize
Runnable
etc

No comments:

Post a Comment