Computer Science 132
Introduction To Computing II

Dickinson College
Spring Semester 2000
Grant Braught

/** * SuperClass.java - * A super class for the demonstration of inheritance. * * @author Grant William Braught * @author Dickinson College * @version 4/5/2000 */ class SuperClass { // Class Data: It is fine to initialize the class // data in its declaration because it pertains to // the entire class. private static int numSuper = 0; // Instance Data: This is declared here and initialized // in the constructors so that it can be unique for // each instance of the object. private int a, b; /** * Default no-arg constructor that initializes * the instance data to 0 and increments the number * of SuperClass objects in existence. */ SuperClass() { a = 0; b = 0; numSuper++; } /** * Constructor that provides initial values for * the instance data. * * @param inita Initial value for instance data a. * @param initb Initial value for instance data b. */ SuperClass(int inita, int initb) { a = inita; b = initb; numSuper++; } /** * methodOne * * @return the sum of a and b. */ public int methodOne() { return a + b; } /** * methodTwo * * @return a * b */ public int methodTwo() { return a * b; } /** * Return a string representation of the object. * * @return a string representation of the object. */ public String toString() { return "numSuper = " + numSuper + "; a = " + a + "; b = " + b; } }

SuperClass.java : javadoc documentation.