Let's design a class Fraction. 

Steps:

(a) instance variables

(b) constructors

(c) instance methods

Nathan says: numerator, denominator

Adrian says: 

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\dgerman\Desktop>javac Fraction.java

C:\Users\dgerman\Desktop>java Fraction
Test of operations:
  Add: 2/3 + (-2/3) = 0
  Sub: 2/3 - (-2/3) = 4/3
  Mul: 2/3 * (-2/3) = (-4/9)
  Div: 2/3 / (-2/3) = (-1)
Test of predicates:
  1. Does 2/3 equal (-2/3)?  The answer is: false
  2. Is (-4) an integer? The answer is: true
  3. Does 0 equal 0? The answer is: true
  4. Is 5/8 greater than 2/3? The answer is: false

C:\Users\dgerman\Desktop>

Adrian says: these examples are a bit deceiving. 

Let me give you more concrete examples:

import java.math.BigDecimal; 

class Example {
  public static void main(String[] args) {
    double a = 4.35; 
    double b = 100; 
    System.out.println( a + " * " + b + " = " + a * b );
    BigDecimal m, n;
    m = new BigDecimal("4.35"); 
    n = new BigDecimal("100"); 

    BigDecimal q = m.multiply(n); 

    System.out.println( m + " * " + n + " = " + q ); 
  }
}

Note: do not (or maybe do) try with new BigDecimal(4.35) because ...

Question 1: consider the following definition 

class Fraction {
  public static void main(String[] args) {

  } 
}
 
Is this defining objects of type Fraction? 

Yes.

Question 2: How does this work?

class Fraction {

  public String rctmpx() {
    return "I am an empty Fraction. Hello."; 
  } 

  public static void main(String[] args) {
    Fraction a = new Fraction(); 
    System.out.println( a.rctmpx() ); 
  } 
}

What if that line is

    System.out.println( a ); 

Then we're back to something pithy and incomprehensible: Fraction@23fc4bec

class Fraction {

  public String toString() {
    return "I am an empty Fraction. Hello!"; 
  } 

  public static void main(String[] args) {
    Fraction a = new Fraction(); 
    System.out.println( a.toString() ); 
  } 
}

Now let's try making the line in main:

    System.out.println( a ); 

What does this do? 

class Fraction /* extends Object */ {
  // which means we inherit toString (that prints Fraction@23fc4bec

  // so we usually redefine (override) public String toString() { ... }

  // from outside dynamic method lookup acts 
}

So we asked Andrew and Austin and Jeremy and we got:

class Fraction {
  int numerator, denominator;

  Fraction(int a, int b) {
    this.numerator = a;
    this.denominator = b;
  }


  public String toString() {
    return "I am a fraction: " + this.numerator + "/" + this.denominator; 
  } 

  public static void main(String[] args) {
    Fraction a = new Fraction( 2,3 ); 
    System.out.println( a ); 
  } 
}