Saturday, May 30, 2015

Interface

package package1;

// INTERFACE
//Different class ko common methods harulai INTERFACE create garera rakhna milxa...
// Interface is the PROTOTYPE or just a way to extrace the common abstrace interface
// properties or the method
// In the interface we have to make the method without body which are also known as abstract method.
// Class always IMPLEMENTS the interface and OVERRIDE all it abstract methods
// We can't make an object of the interface


public interface Interface1 {

public void namEmp();
public abstract void workEmp();

}

-------------------------------------------------

package package1;

public class Class1 implements Interface1 {
public static void main(String[] args) {

}

@Override
public void namEmp() {

}

@Override
public void workEmp() {
}
}

-----------------------------------------------

package package1;

public class Class2 implements Interface1{

public static void main(String[] args) {

}

@Override
public void namEmp() {
}

@Override
public void workEmp() {
}
}

No comments:

Post a Comment