CS 4773 Object Oriented Systems
Midterm Review: Spring 1999
Midterm solutions
Exam Review: The exam will be closed book.
- Java in general: writing simple Java code
- The Java programming model - primitive and reference types
e.g. What does the following code do?
- Using threads: internal and external
- Object oriented programming concepts and how they are implemented in Java
- Responsibilities
- Describe behavior in terms of an object in terms of
what should be accomplished, rather than
the method to accomplish it.
- Encapsulation
- The internal structure (implementation) should be hidden from the user.
- The internal structure should also be protected from the misuser.
- Java uses private and protected to hide structure.
- Classes and Instances
- An object is an instance of a class.
- A class defines the behavior of the objects in the class.
- In Java, variables can be either instance variables (one for each
instance) or class variables (shared by all instances).
Similarly for methods.
- Class Hierarchies and Inheritance
- Java uses extends
- Specialization or extension:
new class has all of the properties of old plus more
- Construction: just use the methods of the parent, but these
may not be visible to the outside
- Combination (multiple inheritance): Java does not support this
- Replacement: Java can override methods of the parent.
- Refinement: supplementing the actions of the parent.
Java uses super.
- Java uses implements
- Specification: methods of parent are incompletely specified
- Assignment
- Copy semantics: Java uses this for primitive types.
Also, some object have a clone method.
- Pointer semantics: Java uses this for all reference types.
- Copy on Write: A method of implementing copy semantics
- Equality
- identity: Also called pointer equivalence
Java uses this for reference types.
- member equality: Also called structural equivalence
Java uses this for primitives.
Also, some objects have an equals method.
- Polymorphism
- Java does not support operator overloading.
- Java does not support polymorphic variables.
- Java does not support templates, parameterizing a class or function
by use of a type.
However, you can pass an Object as a parameter to a method,
and determine the type at run time.
- Java does support the overloading of methods.