Chapter 10
Using Classes

   10.1 Getting Access
   10.2 Constructors
   10.3 Using Instance Methods
   10.4 Using Class Methods
   10.5 Accessing Fields
   10.6 Assignment #11: Referencing Constructors and Methods

10.1 Getting Access

10.2 Constructors

10.3 Using Instance Methods

import java.util.Date; 
class prg{ 
  public static void main( String [] args ){ 
    Date a, b; 
    int c; 
    a = new Date ( 1L ); 
    b = new Date ( 2L ); 
    c = a.compareTo( b ); 
} } 

10.4 Using Class Methods

        // java.lang.Math: static double abs(double a) 
class prg{ 
  public static void main( String [] args ){ 
    double a, b; 
    a = -1.2; 
    b = Math.abs( a ); 
} } 

10.5 Accessing Fields

Exercises

10.6 Assignment #11: Referencing Constructors and Methods

Due: We, Apr 30, midnight

Consider the following incomplete program.

class lab11{ 
   public static void main(String[] args){ 
      Integer in; 
      in = new Integer (  ); 
      System.out.println( in ); 
      Long ; 
      ln = new Long (  ); 
      System.out.println( ln ); 
      Boolean bo; 
      bo = new  ( false ); 
      System.out.println( bo ); 
      Double db; 
       = new Double (  ); 
      println(  ); 
      java.util.Date da; 
      da = new Date (  ); 
      System.out.println( da ); 
      String st; 
      st = new String("A string. "); 
      st = concat ( st ); 
      System.out.println( st ); 
 } } 
Add the missing code to the program, so that it will produce the following output.
1234 
123456789012345 
false 
1.2E-33 
Sat Jan 01 00:00:00 EST 2000 
A string. A string. 
Notes:

Note: Files that fail to compile, and execute when applicable, will not be examined. They will be awarded a grade of 0 points.

Q&A