Close
Close

Bank

   gopika

A boy has his money deposited $1000, $1500 and $2000 in banks-Bank A, Bank B and Bank C respectively. We have to print the money deposited by him in a particular bank.

Create a class 'Bank' with a method 'getBalance' which returns 0. Make its three subclasses named 'BankA', 'BankB' and 'BankC' with a method with the same name 'getBalance' which returns the amount deposited in that particular bank. Call the method 'getBalance' by the object of each of the three banks.


Answers

  •    Psycho

    class Bank{

    int getBalance(){ return 0; }

    }

    class BankA extends Bank{

    int getBalance(int balance) { return balance; }

    }

    class BankB extends Bank{

    int getBalance(int balance) { return balance; }

    }

    class BankC extends Bank{

    int getBalance(int balance) { return balance; }

    }

    public class practice{

    public static void main(String args[]) {

    BankA a = new BankA();

    BankB b = new BankB(); BankC c = new BankC();

    System.out.println("$" +a.getBalance(1000));

    System.out.println("$" +b.getBalance(1500));

    System.out.println("$" +c.getBalance(2000));

    }




  •    Wuzzy

    My brother has completely lost his mind with his games! At first there was some nonsense, where he drained the scholarship for strengthening the troops, and now he went even further - he started playing in an online casino https://duckdice.io/dice/usdc-usd-coin and, most surprisingly, he also dissuades in response that it is very profitable, you see. What profit can there be here?



  •    newquestions

    Bank investments are the most pathetic investments, methinks.Good for the housewives that are unwilling to keep their money under the matress. Please try one more time.



  •    CarlMarx

    Under some circumstances banks can be good too. And your mattress has nothing to do with that. But of course if you wish to increase the leverage of your profits, you need to learn to work with more financially aggressvie tools. What do you think of Bitcoin, forex or shares? I trade Bitcoin, learned it with Bitcoin Decode that my boss once almost forced me to use because I had always been complaining that I reached a financial ceiling.



  •    seoexpertim

    If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. dot tire codes



  •    Larry Martin

    Rite Worx, your reliable local contractors in Dearborn Heights MI, prioritize community needs. With unmatched dedication, we bring exceptional craftsmanship to your doorstep. Trust us for all your construction needs.



Ask Yours
Post Yours
Write your answer