Task-23/01/2025

Task 4:

Assignment – 4

GOAL: Understanding Multilevel Inheritance, Abstraction

Create an abstract class called HeadOffice.
Have below normal methods in it.
2.1. public void check_accounts(int amount)

Have a print statement inside here
2.2. pub…


This content originally appeared on DEV Community and was authored by Neelakandan R

Task 4:

Assignment - 4

GOAL: Understanding Multilevel Inheritance, Abstraction

  1. Create an abstract class called HeadOffice.
  2. Have below normal methods in it. 2.1. public void check_accounts(int amount)
    • Have a print statement inside here 2.2. public int pay_tax(int amount)
    • return this.amount from here
  3. Have an abstract method as below. 3.1. public abstract void receive_Customers()
  4. Create another abstract class called Branch_Plan as sub class of HeadOffice
  5. Have main method in it.
  6. Add a print statement inside main method.
  7. Add below method
    • public void do_interview()
    • Have a print statement inside here.
  8. Create another class 'Branch' as sub class of Branch_Plan
  9. Handle abstract methods here with print statements.
  10. Create an instance called 'branch' for Branch class.
  11. Confirm the below methods can be called.
    • public void check_accounts(1000)
    • public int pay_tax(2000)
    • Check if value is returned.
    • public void do_interview()
package B14;

public abstract class HeadOffice {

    public void check_account(int amount) {
        System.out.println("amount" + amount);
    }

    public int pay_tax(int amount) {

        return amount;
    }

    public abstract void receive_customer();

}

package B14;

public abstract class Branch_plan extends HeadOffice {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("hi");
    }

    public void do_interview() {
        System.out.println("interview");
    }

    public abstract void receive_customer();

}

package B14;

public class Branch extends Branch_plan {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Branch branch = new Branch();
        branch.do_interview();
        branch.check_account(100);
        int tax = branch.pay_tax(200);
        System.out.println("pay tax" + tax);
        branch.receive_customer();
    }

    public void receive_customer() {
        System.out.println("receive customer detials");
    }
}

Output:

interview
amount100
pay tax200
receive customer detials


This content originally appeared on DEV Community and was authored by Neelakandan R


Print Share Comment Cite Upload Translate Updates
APA

Neelakandan R | Sciencx (2025-01-25T10:16:27+00:00) Task-23/01/2025. Retrieved from https://www.scien.cx/2025/01/25/task-23-01-2025/

MLA
" » Task-23/01/2025." Neelakandan R | Sciencx - Saturday January 25, 2025, https://www.scien.cx/2025/01/25/task-23-01-2025/
HARVARD
Neelakandan R | Sciencx Saturday January 25, 2025 » Task-23/01/2025., viewed ,<https://www.scien.cx/2025/01/25/task-23-01-2025/>
VANCOUVER
Neelakandan R | Sciencx - » Task-23/01/2025. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/25/task-23-01-2025/
CHICAGO
" » Task-23/01/2025." Neelakandan R | Sciencx - Accessed . https://www.scien.cx/2025/01/25/task-23-01-2025/
IEEE
" » Task-23/01/2025." Neelakandan R | Sciencx [Online]. Available: https://www.scien.cx/2025/01/25/task-23-01-2025/. [Accessed: ]
rf:citation
» Task-23/01/2025 | Neelakandan R | Sciencx | https://www.scien.cx/2025/01/25/task-23-01-2025/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.