
CMSC 433, Alan Sussman, U. Maryland
(via Bill Pugh) 1
CMSC433, Spring 2001
Programming Language
Technology and Paradigms
Basic Java, continued
Alan Sussman
October 2, 2001
CMCS 433, Fall 2001 -Alan Sussman 2
Administrivia
•C++ project
–private drivers posted soon, grades by end of week
–comments on other students projects due 10/9
•submit as project 11 (e.g. submit 11 1.txt 2.txt)
–you will get the comments back for your project
•Java project
–default compiler is still 1.2, use the one in
/usr/opt/java130/bin for 1.3
–try using jikes for compiling, in ~pugh/bin
•faster than javac
CMCS 433, Fall 2001 -Alan Sussman 3
Administrivia (cont.)
•Exam next Thursday, Oct. 11
–practice exam on web page by tomorrow, talk about it
on Tuesday
•Guest lecturer on Thursday –Bill Pugh
–he can answer any Java question, and probably most
questions about project, but see TA or Dr. Porter for
detailed project questions on Thursday or Friday
•A warning
–will be checking projects against each other for
similarities (with a program)
•and against similar projects from previous semesters
CMCS 433, Fall 2001 -Alan Sussman 4
Last time -Java
•Overriding methods –dynamic dispatch
–same name, same argument types
–for normal methods, like C++ virtual functions
•run-time type of object, static type of arguments
–for static methods, based on static/declared type of
reference
–use super to get at methods/variables in superclass
•Overloading
–same name, different argument types
CMCS 433, Fall 2001 -Alan Sussman 5
Constructors
•Declaration syntax same as C++
–no return type specified
–method name same as class
•First statement can/should be this(args)or
super(args)
–if those are omitted, super() is called
–must be very first statement, even before variable
declarations
•not used for type conversions or assignments
•void constructor generated if no constructors given
CMCS 433, Fall 2001 -Alan Sussman 6
Static class components
•They belong to the class
–static variables allocated once, no matter how
many objects created
–static methods are not specific to any class
instance, so can’t refer to this or super
•Can reference class variables and methods
through either class name or an object ref
–poor style to reference via object references