Tuesday

Interface in Java and Object Oriented Programming

An interface s similar to class. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.
The interface in Java is a mechanism to achieve abstraction. There can be only abstract methods in the Java interface, not method body. It is used to achieve abstraction and multiple inheritance in Java.
Writing an interface is similar to writing a class. But a class describes the attributes and behaviors of an object. And an interface contains behaviors that a class implements.
Java Interface also represents the IS-A relationship.It cannot be instantiated just like the abstract class. Since Java 8, we can have default and static methods in an interface. Since Java 9, we can have private methods in an interface.
read more......

Why use Java interface

Related Posts:

  • Java Scanner Class in Java Scanner is one of the predefined class which is used for reading the data dynamically from the keyboard. Import Scanner class Syntax java.u… Read More
  • Socket Programming in Java Networking is a concept of connecting two or more computing devices together so that we can share resources like printer, scanner, memory. In… Read More
  • Synchronized Keyword in Java Synchronized Keyword is used for when we want to allowed only one thread at a time then use Synchronized modifier. If a method or block declar… Read More
  • Applet in Java Applet is a predefined class in java.applet package used to design distributed application. It is a client side technology. Applets are run on web … Read More
  • Command Line Arguments in Java If any input value is passed through the command prompt at the time of running of the program is known as command line argument by defaul… Read More

0 comments:

Post a Comment