Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 9th, 2011  |  syntax: None  |  size: 0.52 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }
clone this paste RAW Paste Data