Java Program of Account Manipulation – Abstract class


Yzee bank needs to automate the bank transactions.  There are many accounts, like Savings Account, Current Account, Demat Account and so on.

As start up, they need to automate the Savings Account details. 

You are provided with a public class Customer with private attributes :

                                  int  customerId

                                  String customerName

                                  String emailId

       Appropriate public getters and setters are already written.

Write a public 3 argument constructor with arguments – customerId, customerName and emailId.

Write a public class Account with protected attributes :

                                  int accountNumber

                                  Customer customerObj

                                  double balance

       Uncomment the  public getters and setters provided in the template.

Write a public 3 argument constructor with arguments – accountNumber, customerObj and balance.

Write a public method in Account class as,     

            public boolean withdraw(double amount) – Make this method as abstract.

Write  a public class SavingsAccount with private attribute : 

                                 double minimumBalance

              Uncomment the  public getters and setters provided in the template.

 Make this class SavingsAccount to inherit the Account class.

Write a public 4 argument constructor with arguments – accountNumber, customerObj, balance and minimumBalance.

Implement the  withdraw method  as

     public boolean withdraw(double amount) –  This method should return true if withdraw is successful, else return false.

     In this method, check if

               balance – amount   is greater than the minimum balance.

     If yes, perform withdraw.  Reduce the withdraw amount from the balance and return true.

    If not, return false.

Create a public class Main which has the main method.  Check the correctness of the methods written in these classes.

Note :  All class, methods needs to be declared as public


import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(;
        int a=sc.nextInt();
        int a2=sc.nextInt();
        String b2=sc.nextLine();
        String c2=sc.nextLine();
        Customer c=new Customer(a2,b2,c2);
        double b=sc.nextDouble();
        double d=sc.nextDouble();
        double f=sc.nextDouble();
        SavingsAccount a1=new SavingsAccount(a,c,b,d);
        boolean e=a1.withdraw(f);
        System.out.println("withdraw successful");

abstract public class Account {
protected int accountNumber;
protected Customer customerObj;
protected double balance;
public   Account(int accountNumber,Customer customerObj,double balance)
    public int getAccountNumber() {
		return accountNumber;

	public void setAccountNumber(int accountNumber) {
		this.accountNumber = accountNumber;

	public Customer getCustomerObj() {
		return customerObj;

	public void setCustomerObj(Customer customerObj) {
		this.customerObj = customerObj;

	public double getBalance() {
		return balance;

	public void setBalance(double balance) {
		this.balance = balance;
    abstract public boolean withdraw(double a);

public class Customer {
	private int  customerId;
	private String customerName;
	private String emailId;
	public Customer(int customerId, String customerName, String emailId) {
		this.customerId = customerId;
		this.customerName = customerName;
		this.emailId = emailId;

    //Getters and Setters
	public int getCustomerId() {
		return customerId;

	public void setCustomerId(int customerId) {
		this.customerId = customerId;

	public String getCustomerName() {
		return customerName;

	public void setCustomerName(String customerName) {
		this.customerName = customerName;

	public String getEmailId() {
		return emailId;

	public void setEmailId(String emailId) {
		this.emailId = emailId;

public class SavingsAccount extends Account{
    private double minimumBalance;

    public SavingsAccount(int accountNumber,Customer customerobj,double balance, double MinimumBalance)

    public double getMinimumBalance() {
		return minimumBalance;

	public void setMinimumBalance(double minimumBalance) {
		this.minimumBalance = minimumBalance;
   public boolean withdraw(double amount)
           return true;
       return false;



  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

4 thoughts on “Java Program of Account Manipulation – Abstract class”

  1. Oh my goodness! an incredible article dude. Thank you Nonetheless I’m experiencing situation with ur rss . Dont know why Unable to subscribe to it. Is there anybody getting an identical rss problem? Anybody who is aware of kindly respond. Thnkx

  2. Thanks for your useful post. Through the years, I have been able to understand that the particular symptoms of mesothelioma cancer are caused by a build up connected fluid between lining of your lung and the upper body cavity. The ailment may start within the chest area and propagate to other limbs. Other symptoms of pleural mesothelioma include fat reduction, severe inhaling and exhaling trouble, a fever, difficulty ingesting, and infection of the neck and face areas. It needs to be noted that some people having the disease tend not to experience just about any serious signs at all.

  3. I do not even know how I finished up right here, but I assumed this put up was once good.
    I do not know who you’re however definitely you’re going
    to a well-known blogger should you aren’t already.

Leave a Comment

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