Guest User

Untitled

a guest
Jul 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. /*
  2. * Interface unlike abstract classes can have only abstract methods
  3. * Interface unlike abstract classes cannot have constructors
  4. * Interfaces will need to be implemented by child classes
  5. * All the variables of interface should be static and final, Interface variables are static because Java interfaces cannot be instantiated in their own right
  6. * 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
  7. * 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
  8. * Interfaces in JAVA 8 can have default methods with default functionality
  9. * 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
  10. */
  11.  
  12. public interface EmployeeInterface {
  13.  
  14. //Variables in interface
  15. public static final Integer empBaseSalary = 100;
  16.  
  17. //Declare abstract method
  18. public abstract void contractorSalary ();
  19. public abstract void permSalary ();
  20.  
  21. //Declare default behaviour
  22. public default void welcomeMessage() {
  23. System.out.println("Welcome to the company!");
  24. }
  25. }
Add Comment
Please, Sign In to add comment