Questions 1-5:

import java.math.BigDecimal; 

public class FirstFive {
  public static void main(String[] args) {
    BigDecimal 
      one = new BigDecimal("1"), 
      two = new BigDecimal("2"), 
      three = new BigDecimal("3"), 
      four = new BigDecimal("4"), 
      five = new BigDecimal("5");      
    System.out.println( one.add(two) ); // prints 3 (which is equal to 1 + 2)
    System.out.println( two.multiply(three) ); // prints 6 (which is equal to 2 * 3)
    System.out.println( one.subtract(two.subtract(three.subtract(four))) ); // prints -2 which is (1 - (2 - (3 - 4)))
    System.out.println( one.subtract(two).subtract(three).subtract(four) ); // prints -8 or the value of 1 - 2 - 3 - 4
    System.out.println( two.multiply(three).subtract(four.multiply(five)) ); // prints -14 or the value of 2 * 3 - 4 * 5
  }
}

If you run this you get:

Welcome to DrJava.  Working directory is C:\Users\cogli\Desktop\early evaluation exam
> run FirstFive
3
6
-2
-8
-14


Questions 6-17: 

public class SixToSeventeen {
  public static void main(String[] args) {
     System.out.println("\n\t\\\"".length()); // prints 4
     System.out.println("tomato".charAt(2) - 'n'); // prints -1
     System.out.println((char)('a' + 3)); // prints d
     System.out.println('q' - 'h'); // prints 9
     System.out.println(2 / 3 * 3); // prints 0
     System.out.println(3 * 2 / 3); // prints 2
     System.out.println(false && false || true); // prints true
     System.out.println(false && (false || true)); // prints false
     System.out.println(13 / 7 + 5 % 7); // prints 6
     System.out.println(13 / ( 7 + 5) % 7); // prints 1
     System.out.println("substring".substring(3)); // prints string
     System.out.println("automaton".substring(2, 8)); // prints tomato
  }
}

Questions 18-21: 

18. if (n == 0) { b = false; } else { b = true; }

This is the same as b = (n != 0); 

19. if (n < 1) { b = true; } else { b = n > 2; }

This is the same as b = (n < 1) || (n > 2);

20.   n == 0 ? b = false : b = true

This is the same as 18. 

21. (n > 3) || (! (n <= 5))

This is the same as (n > 3) || (n > 5)

Which is the same as n > 3

Questions 22-24:

public class TwentyTwoToTwentyFour {
  public static void main(String[] args) {
    {
      int x = 18, y = 10; if (x < 10) { if (x > 5) y = 1; } else y = 2;
      System.out.println(y); // prints 2
    }
    {
      int x = 18, y = 10; if (x < 10) if (x > 5) y = 1; else y = 2;
      System.out.println(y); // prints 10
    }
    {
      int x = 18, y = 10; if (x < 10) { if (x > 5) y = 1; else y = 2; }
      System.out.println(y);  // prints 10
    }
  }
}

Question 25:

class Circle {
  Point center;
  int radius;
  Circle(Point center, int radius) {
    this.center = center;
    this.radius = radius;
  }
  boolean overlaps(Circle other) {
     return this.center.distanceTo(other.center) <= this.radius + other.radius; 
  }
}