Unit 3 -- Csc 115 Spring 2004 SO1/S02
Learning Objectives for this week
In this unit you will learn the basic concepts underlying the following features in Java and learn
how to use them to do object oriented software design:
- Packages
- Inheritance
- Modifiers
Learning Resources for this week
Lecture slides:
3-00Design.ppt
Sample programs as found in the source directory of
this project:
- To demonstrate constructors:
- To demonstrate simple inheritance concepts:
- To demonstrate class modifiers:
- To demonstrate member modifiers:
- To demonstrate usage modifiers for fields and methods (static and final):
- To demonstrate class variables and class methods (use of static):
Reading Assignment:
Read Chapter 2 and make sure you understand it!
Activities
Short Answer Questions
Answer the following questions:
- What is the difference between "overriding" and "overloading"?
Give an example of when you might use each of these concepts.
- What concept does the keyword "extends" relate to?
When would you use it? How about "inherits"?
- For the following phrases, say if they are
True or False and explain your answer
- A final class cannot be subclassed.
- The protected modifier can be applied to classes, methods and fields
- Every class in Java is a descendent of the java.lang.Object class.
- A string is really the same as an array of characters in Java.
Coding Practice
- Explore the examples posted with your lecture slides.
Also see the pirates package.
There are a few questions scattered throughout the code to point out key concepts.
Take as much or as little time as you like, if you get stuck, refer to your notes and textbook, and then try again!
Make copies of them in a different directory so you keep your original examples intact.
In particular
- shapes/Rectangle.java
has not been fully implemented and can be extended.
- Load these files, explore and answer the questions we posed within the code for the
Pirates, Captain, Deckhand and MainPirates classes in the pirates package.
Course concepts covered: Usage modifiers, super, inheritance
Go to the course website