Contact Us || Privacy Policy || About Us |
|
Interface in Java | Example→ An interface is basically a kind of class, variable and methods. but difference is that interface define only Abstract method and Constant variable. → It is the responsibility of the class that implements an interface to define the code for implementation of these method. → In interface all the method are abstract method so we don't need to the abstract keyword before method. → In interface, all variable are define with "final" adn "static" keyword. → We can implements or inherit the interface one or more than within the class using "implements" keyword instead of "extends" → We want to inherit the one interface from other interface then we will use ""extends" keyword. Syntax![]()
Relationship between classes and interfaces![]() Interface ExampleOutput:- ![]()
Next TopicPackage in Java
|