Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Interface unlike abstract classes can have only abstract methods
- * Interface unlike abstract classes cannot have constructors
- * Interfaces will need to be implemented by child classes
- * All the variables of interface should be static and final, Interface variables are static because Java interfaces cannot be instantiated in their own right
- * The question may arise, as to why the variables in abstract can be other than final and static, since even in them abstract classes are not instantiated, the reason for this
- * as explained in some JAVA documentation is the fact that abstract classes framework is extended and not implemented, it is considered to be a partial class which can be changed
- * Interfaces in JAVA 8 can have default methods with default functionality
- * Default methods in interfaces do not mandatorily overridden by child classes, they can be called and used from child objects just like the interface methods
- */
- public interface EmployeeInterface {
- //Variables in interface
- public static final Integer empBaseSalary = 100;
- //Declare abstract method
- public abstract void contractorSalary ();
- public abstract void permSalary ();
- //Declare default behaviour
- public default void welcomeMessage() {
- System.out.println("Welcome to the company!");
- }
- }
Add Comment
Please, Sign In to add comment