Inheritence_in_interface
package com.company;
interface SampleInterface{
void meth1();
void meth2();
}
interface ChildSampleInterface extends SampleInterface{
/* we can extend from an interface for inheritence to a interface
and we can't do with a implements and a class
*/
void meth3();
void meth4();
}
class MySampleClass implements ChildSampleInterface{
public void meth3(){
System.out.println("Meth3");
}
public void meth4(){
System.out.println("Meth4");
}
public void meth1(){
System.out.println("Meth1");
}
public void meth2(){
System.out.println("Meth2");
}
}
public class inheritence_interface {
public static void main(String[] args) {
MySampleClass m=new MySampleClass();
m.meth1();
m.meth2();
m.meth3();
m.meth4();
}
}
o/pMeth1
Meth2
Meth3
Meth4
Comments
Post a Comment