Java Program of Inheritance-Account


Atlas Bank is providing services for various accounts like Savings, Current,Loan for Education ,Vehicle, Home, Personal. As a first step they wanted to automate Savings Account. As a java developer, design the classes as per the given specifications

Create a Account class with the following private attributes:

accntNo – int

accntHolderName – String

accntBalance – double

Provide the appropriate getters/setters

Create another class SavingsAccount which is of type Account with the additional private attributes:

float minBalance

Provide appropriate getters/setters

Override the toString() method in the SavingsAccount class to display the details in the below format


Example: AccountNo:1000-AccountHolderName:Peter-AccountBalance:80000-MinimumBalance:1000

In the TestMain class ,  get the details of Savings Account set the details and print the reference of SavingsAccount

Sample Input/Output:

Enter the AccountNumber: 4000

Enter the Account Holder Name: Rose

Enter the Account Balance: 4000

Enter the Minimum Balance: 500



import java.util.*;
public class TestMain
    public static void main(String[] args)
        Scanner sc=new Scanner(;
        System.out.println("Enter the AccountNumber: ");
        int an=sc.nextInt();
        System.out.println("Enter the Account Holder Name: ");
        System.out.println("Enter the Account Balance: ");
        double ab=sc.nextDouble();
        System.out.println("Enter the Minimum Balance: ");
        float mb=sc.nextFloat();
        SavingsAccount sa=new SavingsAccount();

public class Account
    private int accntNo;
    private String accntHolderName;
    private double accntBalance;
    public void setAccntNo(int accntNo)
    public int getAccntNo()
        return accntNo;
    public void setAccntHolderName(String accntHolderName)
    public String getAccntHolderName()
        return accntHolderName;
    public void setAccntBalance(double accntBalance)
    public double getAccntBalance()
        return accntBalance;

public class SavingsAccount extends Account
    private float minBalance;
    public void setMinBalance(float minBalance)
    public float getMinBalance()
        return minBalance;
    public String toString()
        String str="AccountNo:"+String.valueOf(getAccntNo())+"-AccountHolderName:"+getAccntHolderName()+"-AccountBalance:"
        return str;


  1. Interest Calculator – Interface Concept
  2. Bank – Abstract concept
  3. Inheritance – Account
  4. Contact Details of Hosteller
  5. PF and Salary Calculation
  6. Check for Existence of Customer – equals method
  7. Account Manipulation – Abstract class
  8. Employee Loan Eligibility – Polymorphism

1 thought on “Java Program of Inheritance-Account”

  1. Thanks for your submission. I also believe laptop computers are getting to be more and more popular these days, and now are often the only sort of computer utilised in a household. It is because at the same time actually becoming more and more reasonably priced, their processing power is growing to the point where they may be as effective as desktop out of just a few in years past.

Leave a Comment

Your email address will not be published. Required fields are marked *