CMIS 141A

Java Class Example -Point and Circle classes found here.
Suggested exercise -complete the circumference method and test it in the main.

Time class example . Complete the tick() method that advances the time by one second.

Here is the Time class example with the tick() method. In addition the main method illustrates the JButton and the JLable components. Both the components can render text as well as images. The images used are starz and impala . Also note the use of the sleep() method to delay the loop execution.

Sample Applet using java swing components.


For Java reference and tutorial links go to CMIS 102A Page.

Formatting example for Java 1.5 found here.


Assignment 1
Assignments 2 and 3
Assignment 4
Assignment 5
Assignment 6
Assignment 7

Classes and Objects

Class Student has five instance variables - (first_name, last_name, id_number; score, year) and five methods -1) changeLastName 2) setScore 3)calcGrade 4) setYear 5) getYear. In addition there is the toString method and two constructors :- Student with two parameters and student with three parameters.

The constructor is overloaded as we do not give separate names to the different constructors, the compiler recognizes the proper call only through the number of parameters (signature). Similarly methods can also be overloaded through different combinations of parameters.

The toString() method is overridden. Which means that it already existed but was designed to display the memory location of the Object. The Student class Eoverrides it my redefining this method to suite the display requirements. All classes have a toString() method that behaves as described above Edisplay memory location.