
CMSC 433, Alan Sussman, U. Maryland (via
Bill Pugh) 1
CMSC433, Spring 2001
Programming Language
Technology and Paradigms
Basic Java, continued
Alan Sussman
February 12, 2002
CMCS 433, Spring 2002 -Alan Sussman 2
Administrivia
•Project 1 due Wednesday, 6PM
–threads issue
–anyone not get email to reflector?
–projects for commentary emailed after late
deadline
•Second Java project posted soon
CMCS 433, Spring 2002 -Alan Sussman 3
Last time -Java
•Instance variable/method modifiers
–both: public, protected, package, private, static
–method: abstract, final, native, synchronized
–field: transient, volatile, final
•Overriding/Overloading
•Constructors
–call another constructor or super() first
•Static methods/instance variables
–associated with Class object
–Class object used for reflection operations
•Interfaces are types
CMCS 433, Spring 2002 -Alan Sussman 4
Types
•A type describes a set of values that can be:
–held in a variable
–returned in an expression
•Types include:
–primitive types –boolean, char, short, int , …
–Reference types:
•Class types
•Array types
•Interface types
CMCS 433, Spring 2002 -Alan Sussman 5
Class types
•Using the name of a class as a type means a
reference to an instance of that class or a
subclass is a permitted value
–a subclass has all the fields of its superclass
–a subclass has all the methods of its superclass
•null is also an allowed value
CMCS 433, Spring 2002 -Alan Sussman 6
Array types
•If Sis a subtype of T
–S[] is a subtype of T[]
•Object[] is a supertype of all arrays of reference
types
•Storing into an array generates a run-time check
that the type stored is a subtype of the declared
type of the array elements
•Performance penalty?
•Similar (and maybe worse) problems in C++