DEV Community

hema latha
hema latha

Posted on

Assignments 4

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. public int pay_tax(int amount)
    return this.amount from here
Have an abstract method as below.
3.1. public abstract void receive_Customers()
Create another abstract class called Branch_Plan as sub class of HeadOffice
Have main method in it.
Add a print statement inside main method.
Add below method

public void do_interview()
    Have a print statement inside here.

Create another class ‘Branch’ as sub class of Branch_Plan
Handle abstract methods here with print statements.
Create an instance called ‘branch’ for Branch class.
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()
Enter fullscreen mode Exit fullscreen mode

program
package task;

public abstract class Headoffice {

public void check_accounts(int amount)
{
System.out.println("headoffice1");
}
public int pay_tax(int amount)
{
System.out.println(amount);
return amount;
}
public abstract void receive_Customers();

}

package task;

public abstract class Branchplan extends Headoffice {
public static void main(String[] args) {
System.out.println("plan");
}

public void do_interview()
{
System.out.println("interview_output");
}
}
package task;

public class Branch extends Branchplan{
public static void main(String[] args) {

      Branch branch = new Branch();
      branch.check_accounts(1000);
      int amount = branch.pay_tax(2000);
      branch.do_interview();
Enter fullscreen mode Exit fullscreen mode

}

}
out put --

headoffice1
2000
interview_output

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more