Interfaces


Like a class, an interface can have methods and variables, but the methods declared in interface are by default abstract (only method signature, no body).
The syntax for declaring an interface is given on the right:
interface <interface_name> {
  // Declare constant fields.
  // Declare methods that are abstract by default.
}

To declare an interface, use interface keyword. It is used to provide total abstraction. That means all the methods in interface are declared with empty body and are public and all fields are public, static, and final by default. A class that implements interface must implement all the methods declared in the interface. To implement interface use implements keyword.




      A mother asks her young sons what they want for breakfast.    
      The first little boy says, “I’ll have some @#$%^& pancakes.”    
      The mother angrily sends him to his room for cursing.    
      She glares at the other little boy and asks,    
      “What do you want for breakfast?!”    
      The second boy says, “Well, I sure don’t want the @#$%^& pancakes!”