Shadowing Inherited Variables from Parent Class

  1. Shadow variables from parent's class:

    Example: shadowing the "balance" variable from parent's class
       public class BankAccount
       {
          private double balance;
          ...
       }
       
       public class CheckingAccount extends BankAccount
       {
          private double balance;  // Shadows "balance" in BankAccount   
          ...
       }
       
    

    Result:

    NOTICE:

  2. DEMO programs:

  3. CONCLUSION: