सीधे मुख्य सामग्री पर जाएं

#50 What is Interface in Java | Real life Example of Interface Vehicle & Customer

package com.sudhirtheindian2.java123;

import java.time.temporal.ChronoUnit;

interface vehical{
String name = "honda"; // public+static+final
int speed = 100;

void start();
void stop();
}


public class MyCustomer implements vehical {

@Override
public void start(){

System.out.println("for start the vehical , insert the key & press the start button"+name);
}

@Override
public void stop() {
System.out.println("for stop the vehical exit the key");

}

public static void main(String[] args) {


// What is interface in java ?

// 1 interface just like a class,

// 2 to achieve interface in java by the help
// of implements interface keyword

// Notes about interface

// 1 by default variable are public +static+final inside a interface
// 2 by default methods are public and abstract
// 3 from jdk 1.8 version interface can have default of static method





MyCustomer m = new MyCustomer();
m.start();
m.stop();
System.out.println(name);



}
}

टिप्पणियाँ

इस ब्लॉग से लोकप्रिय पोस्ट