Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Employee {
- public int computeSalary() {
- return 1000;
- }
- final void doTheJob() {
- System.out.println("WORK!");
- }
- }
- interface IEmpWithBonus {
- default int getBonusSalary() {
- return 100;
- }
- }
- class PermanentEmployee extends Employee implements IEmpWithBonus {
- @Override
- public int computeSalary() {
- return super.computeSalary() * 2;
- }
- }
- class Intern extends Employee {
- @Override
- public int computeSalary() {
- return super.computeSalary() / 2;
- }
- }
- public class Main {
- public static void main(String[] args) {
- PermanentEmployee permanentEmployee = new PermanentEmployee();
- System.out.println(permanentEmployee.getBonusSalary());
- Intern intern = new Intern();
- System.out.println(intern.computeSalary());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement