title: Why is the toString() method being called when I print an object?
body: <p>I can't seem to understand why when  I use println method on the quarter object, it returns  the value of the toString method. I never called the toString method why am I getting the return value?</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          Quarter q = new Quarter();
          Nickel n = new Nickel();
          System.out.println(q);
          System.out.println(n);
      }
  }
  
  public abstract class Money {
      private int value;
  
      public Money(int v) {
          value=v;
      }
  
      public abstract int getValue();
  
      protected int myValue() {
          return value;
      }
  
      public abstract String toString();
  }
  
  public abstract class Coin extends Money {
      public Coin(int value) {
          super(value);
          System.out.println("I am a coin, my value is " + getValue());
      }
  }
  
  public class Quarter extends Coin {
      public Quarter () {
          super(25);
      }
  
      public int getValue() {
          return myValue();
      }
  
      public String toString() {
          return "A Quarter is "+getValue();
      }
  }
  
  public class Nickel extends Coin {
      public Nickel () {
          super(5);
      }
  
      public int getValue() {
          return myValue();
      }
  
      public String toString() {
          return "A "+this.getClass().getName()+ " is "+getValue();
      }
  }
  </code></pre>