CS202 Site Index
- Main
- Information
- Registration
- Announcements
- Lectures
- Assignments
- Submit
- View
- Reference
- Passwords
Java logo CS202 - Spring 1999
Transition to Java

Lectures: Week 1

divider line
Mon, 25 Jan  
  • Course information (also refer to info page)
  • Assignment #1
  • Portability: how Java works
  • Hello world
  • Primitive data types: int, long, char, ...
  • classes
  • objects (instances of classes)
  • class methods
  • class variables
  • static and instance
  • public and private
  • An example (to be continued)
  • Reading:
    Depending on your familiarity with Java, and other languages it may help to read Ch 1-15 of "On to Java" (they are very short) and/or Ch 1-3 of "Java in a Nutshell". Also refer to the links (specifically the tutorial) on the reference page.
  • Assignment:
    Assignment is available on the web site. Students should start working on it early and use the newsgroup and office hours to ask questions, as not all the required material can be covered in class. Use the reference page provided on this web site. It contains links to some invaluable resources: specifications, tutorials, examples, documentation.

 
Wed, 27 Jan  
  • Review:
    Java design goals: simple and familiar, object oriented, robust and secure, architecture neutral and portable, high-performance, interpreted, threaded, dynamic
    Portability: bytecodes and primitive types well defined
    Java environment: .java (source code), javac (compiler), .class (bytecode), java (virtual machine)
    Hello World!
    Classes and object
    Objects: have state (variables) and behaviour (methods)
    Class vs. instance fields:
    - common to all objects of class, eg. Time.AM,
    - one copy per object/instance, eg. t.sec
    Class vs. instance methods:
    - use only class data/methods, eg. Queue q=new Queue(); q.enqueue();,
    - use instance data/methods too, eg. double x=Math.sin(pi) [vs. double x=(new Number(pi)).sin();]
  • Public: exposed to all objects
    Private: exposed only within same class
    Protected: exposed to subclasses of this class
  • Inheritance: class Manager extends Employee, Dog/Cat extends Animal
    allows specialization (code reuse) and polymorphism (behaviour depends on type)
  • Abstract vs. concrete: Animal
    can only instantiate concrete classes, must implement all abstract methods in subclasses
    concrete method: die(), abstract method: talk()
    ensures expressions like Animal.talk() are valid for all object instances of subclasses
  • Final:
    classes: can't subclass (error to have abstract, final... Why?)
    methods: can't override/specialize in polymorphic manner
    fields: can't change initial value
  • Interface: totally abstract, eg. Enumeration
    just define the "interface" methods, no implementation

 
Fri, 29 Jan  
  • Review/discussion:
    Enumeration, interfaces, A1
  • Packages:
    package, import, CLASSPATH
  • Constructor:
    no return type, named same as class, called at creation of instance
  • Finalize:
    garbage collection, called once before object destroyed
  • Arrays: can have arrays of any type, is an Object, zero based indexing, length, 2D arrays

divider line
Copyright 1999, Rimon Barr, Cornell University RBcs202-sp99: l.1.html (17598)