hey ,
today we are write a code of inteface in java...
interface motors{//create a class of interface
public void sound();//methods in interface
public void name();
public String person="ankush";//create an object or attributes in interface
}
class car implements motors {//now implements a classs from super class
public void sound() {
System.out.println("piip piip!");
}
public void name() {
System.out.println("volvo");
}
}
public class interfac {
public static void main (String[] args) {
car s=new car();//create an object of class that implements from superclass
s.name();
s.sound();
System.out.println(s.person);
}
}
No comments:
Post a Comment