SHARE
TWEET

Untitled

a guest Dec 9th, 2011 39 Never
  1. ## BankAccount.java
  2. public abstract class BankAccount {
  3.   public String toString() {
  4.     return this.getClass().toString();
  5.   }
  6. }
  7.  
  8. ## CheckingAccount.java
  9. public class CheckingAccount extends BankAccount {
  10. }
  11.  
  12. ## SavingsAccount.java
  13. public class SavingsAccount extends BankAccount {
  14. }
  15.  
  16. ## Main.java
  17. public class Main {
  18.   public static void main(String[] args) {
  19.     BankAccount ca = new CheckingAccount();
  20.     BankAccount sa = new SavingsAccount();
  21.  
  22.     System.out.println(ca);
  23.     System.out.println(sa);
  24.   }
  25. }
RAW Paste Data
Top