Answers for "when to use interface in java"

6

java interface

public interface Exampleinterface {
	
  public void menthod1();
  
  public int method2();

}

class ExampleInterfaceImpl implements ExampleInterface {


  	public void method1()
    {
        //code here
    }
  
    public int method2()
  	{
    	//code here
  	}

}
Posted by: Guest on May-28-2020
0

Interface in Java Implementation

interface Moveable 
{
 int AVG_SPEED = 40;
 void move();
}

class Vehicle implements Moveable 
{
 public void move()
 {
  System.out.println ("Average speed is"+AVG-SPEED");
 }
 public static void main (String[] arg)
 {
  Vehicle vc = new Vehicle();
  vc.move();
 }
}
Posted by: Guest on July-30-2021

Code answers related to "when to use interface in java"

Browse Popular Code Answers by Language