First Course in Java, EDP 158287
FALL 2012 Schedule and Syllabus
Schedule, Tally,
Syllabus, Grading Policy,
Submitting Homework by Email,
Downloading Java If
you use a Mac
Session
|
Date
|
Topic
(and link to lecture notes)
|
Chapter
in Textbook |
Homework Assignment
|
1
|
O4 SEPT
|
Java
Fundamentals
|
1
(pp. 1-30) |
-
Students explain what they
would like to get from the class.
-
Instructor explains class
syllabus: weekly homework (50%) and weekly quizzes (50%) = final grade
-
Format and deadline for
emailing homework
-
Lecture
-
Demo: HelloWorld and
HelloCommandLineArgs
-
In-class assignment: Write,
compile, and run a program that uses multiplication,
division, and modulus.
-
Homework #1:
Download the SDK, configure the SDK (set the PATH), and write a program
that uses the modulus operator % to return the
remainder of the division of the left operand by the right operand.
-
Quiz
|
2a
|
11 SEPT
|
Introducing
Data Types and Operators
|
2
(pp. 31-61) |
Homework
#2: Write a program that uses relational
and logical operators
|
2b
|
11 SEPT
|
Program
Control Statements
|
3
(pp. 63-101) |
Homework #3: Write a program that uses an
if-else-if ladder, a for loop, and a do-while loop |
|
3a |
18 SEPT |
Introducing
Classes, Objects, and Methods |
4
(pp. 103-134) |
Homework #4: Write one .java file that contains
three classes: two classes that each define a parameterized
constructor and a method, such as Dog and Cat. The third class (Demo.java) has the main
method that instantiates the two classes by calling the parameterized constructor of
each class.
For example,
Dog fido = new Dog("watchdog");
The main method then calls the method on each of the newly created objects.
For example, fido.wagTailAtRobbers(); |
3b
|
18 SEPT
|
More Data Types and
Operators
|
5
(pp.135-179, so we skip pp. 166-175) |
In-class Lab: Write a program that
uses the ternary (?) operator, and that also includes the same logic
written using standard if, else statements.
Homework #5: Write a program that
uses String methods listed at
http://download.oracle.com/javase/7/docs/api/java/lang/String.html
- use a String method - in addition to or other than
length() - on an array of strings. Do this by processing the array of
Strings with a for-each loop.
- use two String methods on one or more individual
Strings, that is, Strings that are not processed in
an array of Strings by a loop, but rather in separate statements.
- Note that
println() is NOT a method of the
String class
- OPTIONAL CHALLENGE:
Write two
STATIC methods, one for bullet 1, and the other for bullet 2. Have main call them
by using the class name rather than an object name. For an example of static
method calls, see
session5.htm#static
Study the Strings examples at
http://java.sun.com/docs/books/tutorial/java/data/strings.html
or
http://docs.oracle.com/javase/tutorial/java/data/comparestrings.html
and write a program that does something with Strings
that you consider useful.
-
One use case might be to remove the prefix "Mr. or
Mrs." from a list of names. Another might be to remove the suffix ",
Jr." and ", Sr."
-
Another use case might be to compare two strings and
find any differences or sort them lexically (alphabetically)
|
4
|
25 SEPT
|
A Closer
Look at Methods and Classes
|
6
(pp. 181-223)
|
In-class Lab: Write a program that passes objects to a
method.
Homework
#6: Overloading - Write a program that defines a class with an overloaded constructor
and an overloaded method. For example,
- SavingsAccount constructors for no initial deposit and with initial
deposit
- calculateInterest method for SavingsAccount and for CheckingAccount
- Make sure the class name is a noun that begins with a capital letter,
such as Account, and method name is a verb, such as getName.
If you want more challenge: include a method that calls a constructor
and/or a constructor that calls another constructor using this() -
http://www.write-technical.com/126581/session6/session6.htm#Overloading%20Constructors
|
5
|
02 OCT
|
Inheritance
|
7
(pp. 225-266)
|
In-class Labs:
- Write a program that
demonstrates the order of construction in a multilevel class hierarchy.
- Write an abstract class
called Animal that has at least one abstract method and one
non-abstract method. Extend the abstract class by implementing the
abstract method it inherits. Override a
non-abstract method it inherits.
Homework
#7: Write a program that overrides a method inherited from the
superclass and that uses the keywords this
and super to make
use of both versions. In other words, the subclass will call both this.calculateTax() and super.calculateTax().
Optional challenge:
(1) Create
an abstract class, AbstractRestaurant, with both an abstract method,
calculateTax()
and a non-abstract method,
getPretaxPrice().
(2) Subclass
AbstractRestaurant with
NewYorkStateRestaurant, and make
this
NewYorkStateRestaurant
implement
calculateTax() with the rate of 4.0%.
(3) Make a subclass of
NewYorkStateRestaurant
called
NewYorkCityRestaurant
that overrides
calculateTax() such that this.calculateTax()
charges 12.875%. Call both
this.calculateTax()and
super.calculateTax().
Note: these rates are official and posted at
http://ny.rand.org/stats/govtfin/salestax.html)
|
6
|
09 OCT
|
Packages
and Interfaces
|
8
(pp. 267-293) |
- In-class Lab: create and
import packages.
- Homework #8: Make an IAnimal
interface in one file named IAnimal.java
that specifies the speak()
and eat() methods.
Implement the interface in Dog.java,
and Cat.java. Put
the main method in AnimalDemo.java.
Email an executable .jar
file (not a .zip
file) that includes the .java
files, the .class
files, and the manifest
file that specifies the main class. See the "JAR instructions" in the lecture notes -
http://www.write-technical.com/126581/session8/session8.htm#Jar%20instructions
|
|
7
|
16 OCT
|
Exception
Handling
|
Chapter 9 (pp. 295-323) |
- In class lab: write a
program that uses multiple catch
statements to demonstrate that the catch
statement for a subclass exception must precede the catch statement for a
superclass exception.
- Homework #9:
Write a program with exception handling that uses try,
catch, and finally (or add
exception handling to one of your earlier programs). The program must
catch both a standard and a custom exception.
|
8a |
23 OCT |
Input/Output
(I/O) |
Chapter 10 (pp. 325-366) |
- In class lab: write a
program that compares two files but ignores case (see page 384).
- Homework #10: Write a program that writes characters the user enters at the
keyboard to a file named KeyboardInput.txt.
|
8b
|
23 OCT
|
Threads and Applets
|
Chapter 11 (pp. 367-404) |
- Review of previous chapters to access what we learned
- Learn about Threads and Applets
- Homework
#11 in class: Write a program that uses multiple threads.
- Calculate course grades
- Fill out course
evaluation form
|
Other Books To
Consider
An introduction similar to our textbook, but more
comprehensive and with
less guidance for the non-programmer:
Java: The Complete Reference
Eighth Edition (2011)
by Herbert Schildt
McGraw Hill/Osborne
1000 pages
($33)
Innovative teaching style: photos, cartoons, puzzles, and
whatever else might
keep you from getting bored.
Head First Java, 2nd Edition
by Kathy Sierra & Bert Bates
O'Reilly (2005)
ISBN: 0596007736 ($30)
http://www.oreilly.com/catalog/hfjava/?CMP=IL7015
Handy reference if you do not want to use the API Reference at http://docs.oracle.com/javase/7/docs/api/
(also has a brief introduction for people who are already programmers):
Java in a Nutshell, 5th Edition
by David Flanagan
2005
Series: In a
Nutshell
ISBN 0-596-00773-6
992 pages, $30
More thorough and detailed than what we cover in this
introductory course.
Best for people with a C/C++
background.
Learning Java, 3rd Edition (2005)
Patrick Niemeyer & Jonathan Knudsen
O'Reilly
0596008732
856 pages, $30
http://www.unex.berkeley.edu/cat/course346.html
An elective in the Post-Baccalaureate Certificate in Information Systems and Management and in the Professional Sequence in Database Management
Java—with
its platform independence—is heavily used in Web applications and
middleware that work on Windows, Macintosh, UNIX and other platforms.
Examine fundamental programming concepts, and get an introduction to
object-oriented programming. Upon successful completion of the course,
you are able to write simple applications and are prepared for courses
that assume some familiarity with Java.
You do not need any background in programming to succeed in this course, and Java is easier to learn than C or C++.
You
are welcome to bring your own laptop. The classroom does not provide
computers but does have free wireless Internet access. Download Java SE 7
at www.oracle.com/technetwork/java/javase/downloads/index.html and see the configuration instructions at
www.write-technical.com/126581/session1/syllabus.htm#Download.
X429.9 (2 semester units in EECS)
Our Focus:
Applets
(logic within a web browser) and Swing (graphical user interface) will
be briefly introduced. Today, Java is heavily used in servlets and middleware
(business logic that runs on a server without a graphical user
interface). One example would be web services, such as
https://www.discoverygate.com/webservice/1.0/.
This introductory course for nonprogrammers focuses on the Java
programming language and covers fundamental programming concepts and
basic object-oriented programming. On successful completion of the
course, you will be able to write simple Java applications and be
prepared to undertake courses that assume some background in
object-oriented computer programming and/or the ability to learn Java
skills rapidly.
Criteria for Grading the Homework
- Homework
- Is the
homework emailed on time?
- Does the
header comply with the required format?
- Does the code
compile?
- Does the code
run?
- Does the code
address the assignment problem?
- Does the code
solve the assignment problem?
- Adherence to
structured design methodology and, when appropriate, object-oriented
design
- Simplicity: is the
implementation sufficient, without unnecessary complexity?
- Naming:
- Do variables
and members have consistent names that adhere to standard Java
conventions?
- Are the names
indicative?
- Documentation
(code comments)
- Do the
comments explain briefly the big picture at the top: approach,
algorithm, usage tips?
- Do the
comments make the code easier to understand and maintain, without
stating the obvious or causing clutter?
Attendance
You are responsible for your work. You do not have to contact
the instructor
with a reason of absence.
Withdrawing
If you decide to withdraw, it is your responsibility to make
sure that U.C. Berkeley Extension processes your withdraw request and
removes your name from the final grading form. If your name appears on
the official grading form, the instructor will assign you the grade you
earned at the end of the course.
Grading Options for UCBX Courses
·
CLG -
Credit-Letter-Grade is the normal grading
option.
·
P/NP -
Pass/No-Pass. Requires 70% for a Pass.
·
C/NC -
Credit/No-Credit. A grade of No Credit
will be assigned if you have done
insufficient work for any of the other grading options.
·
W - Withdraw. If
you cannot complete the course,
you will normally be assigned a
grade of NC. Under certain circumstances, you might be eligible to
"Withdraw" from the
course. You must initiate this action directly with UC Berkeley
Extension.
·
INC - Incomplete.
If you have completed 60% of
the course work, but cannot finish the
work by the end of the term, you are eligible for an Incomplete. You
must get the form from Extension and have me sign the form by the last
day of class, then make a copy for your records. I will submit the form
along with the course grades and keep a copy for clearing the
incomplete. See the section below: "Clearing Incompletes".
Method of Assigning Course Grades
·
If you earned a
'B' or better, I assign the
earned grade.
·
If you have at
least a 70% AND you have
requested the P/NP option, I assign a grade of Pass.
·
If you have not
completed 60% of the course
work, I assign a grade of No Credit.
If you
have done 60% - 79% of the course work and have not requested P/NP, I
assign
an Incomplete.
Clearing Incompletes
If
you received an Incomplete, you
have 90 days from the last class meeting.
to submit all remaining
work.
To clear an incomplete, email all the remaining work on one day in a
zip.
Remember
to identify each
assignment with your full name, the term it pertains to, and the name
and EDP number of the course it pertains to.
Clearing incompletes involves significant administrative overhead on my
part.
To minimize
the work, I only address the clearing of incompletes once a month, on
the last
weekend of the
month. Therefore, it may actually be several weeks before I clear an
incomplete
once all work
has been submitted. When you see the updated grades on the website
tally,
contact
Extension directly to get an updated transcript.
Tally Page of Grades for Quizzes and Homework
See explanations on the Tally
page.
- Attach each homework’s
source code file to an email as an attachment,
such as MyHelloWorld.java,
where MyHelloWorld
is the name of the class. If you prefer, you can name your homework
class something like Homework1.
- Include
the numbered quiz questions and answers in the body of the same email that has
the homework .java file as an attachment.
- Do NOT
- send the .class file, that is compiled bytecode (unnecessary because I
want to compile your code)
- insert your source code in the body of the email
(formatting lost)
- attach a ZIP archive (unnecessary unless your project
has multiple source code files)
- BEFORE you send the email to me, please verify the
following:
- your work addresses the assignment (if you have any
doubts, email me beforehand)
- your source code file is named correctly for the class
it contains
- your source code compiles (using only the
command-line compiler)
- the resulting class file runs (using only the
command-line)
- your comments explain what your code does in a clear,
brief manner
- your formatting and naming of class members and
variables conform to Java conventions
- the header comment of the source code file provides
- sample output
- any special usage information (for example, if a
user must type a special argument at the command line)
The
email Subject line should follow this format:
·
Email
SUBJECT line: s03hj,
Homework #1 [where
"hj" represents lastnameInitial firstnameInitial for the student's
name, in this case, HENDRICKS, Jimi] |
The attached Java source code file must contain the following:
|
The
header comment should follow this format:
|
Email Address, Deadline, and Late Penalty
- The timestamp of
your email of the current week's homework to talbert747@gmail.com
must be before
5:00 p.m. on
the SUNDAY after that week's lecture.
- If you email the
homework by 5:00 p.m. SATURDAY I can probably help
you solve any problem you might be having with the homework.
- Note: I do NOT
check email during regular working hours (Monday - Friday: 8 a.m. to 6
p.m.)
- If the timestamp of the arrival of the email is
late, it loses one point. For example, a 5 becomes a 4.
Each 24 hours after the deadline, it loses an additional point. So, 25 hours
late means a 5 becomes a 3.
- To verify that I received your homework,
please check the Tally page after 8:00 a.m.
Tuesday.
How to copy output from the DOS window:
- Click the icon for
the command prompt, which is in the top left corner. A menu appears.

- Select Edit
> Mark
- Drag your cursor over the characters that you
want to mark for saving. This selects the text.
- To copy the text to the clipboard, press the
Enter key.
- Paste the text in
your source code file.
- Recommended: use Edit > Properties to configure
the console for QuickEdit Mode:

Download the Java
Development Kit, Standard Edition - J2SE 7 SDK
[First Course in Java Schedule and
Syllabus:
http://www.write-technical.com/126581/session1/syllabus.htm ]
Download Sun's Standard Edition (SE) JDK (Java Development
Kit) for your computer's platform:
For
Windows or
Linux,
- To verify whether you already have Java configured, start a
command prompt and type java
-version
- If you see java
version "1.7.0_01" or higher, you are already configured.
- Go to http://java.sun.com/
or more, precisely,
http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Under Java Platform, Standard Edition, click the JDK (not JRE) Download button.

- Accept the License Agreement.
- Select your operating system, such as Windows x64.
XP is 32-bit, but most installations of Windows 7 are 64-bit.
- Click
Save File, and make note of the path to which the installer is
downloaded.
TIP: On Windows, it is best if you do
NOT allow the installer to install in the "Program Files" folder. I suggest you
create a
c:\java
folder and install into that.
The installer might have a name similar to
jdk-7u4-windows-x64.exe
- Navigate to the directory to which you downloaded the installer.
- Launch the installer application.
- Grant permission for the installer to run.
- Follow the instructions of the installation wizard.
- Note the directory in which the JDK is being installed. The default location might be
C:\Program Files\Java\jdk1.7.0_04\
- When the installer launches a secondary installer for Java FX, you do
not
need to install Java FX, which is a a new scripting language (separate
from the Java language) that supports mobile devices. (For an overview,
see http://en.wikipedia.org/wiki/Java_FX)
- To verify the installation, open a command-line console (On the Start menu, run "command"), type
java -version and press Enter. You should see something
similar to the following:
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)
- Note that you also get the Java Runtime Environment when
you install the Java Development Kit:
Verify the directory structure of the installation.
For example,
C:\Program Files\Java
should contain:
C:\Program Files\Java\jdk1.7.0_04, and
C:\Program Files\Java\jre7
- Verify that C:\Program
Files\Java\jdk1.7.0_04\bin
contains javac.exe, the
compiler, and java.exe, the interpreter.
- Write down the exact path to the directory with the compiler and interpreter.
- Create a text file named HelloWorld.java as a test application with the following content
and remember, Java is case-sensitive:
class
HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
- In a command console, cd to the directory with
HelloWorld.java and type
javac HelloWorld.java
and remember, Java is
case-sensitive.
Troubleshooting 'javac' is not recognized
- Note that you will probably see this message:
'javac' is not recognized as an internal or external command,
operable program or batch file.
This means that the Windows PATH environment variable cannot find the javac compiler.
- Close this console.
- Remember the path, which might be C:\Program Files\Java\jdk1.7.0_04\bin
- Go to Start > Control Panel > System > Advanced.
- Click Environment Variables.
- Under System Variables, select PATH and click Edit.
- Left-arrow to the beginning of the PATH and paste in the following at the
beginning of the PATH:
C:\Program Files\Java\jdk1.7.0_04\bin;
which represents the
path to the compiler, inside the bin
subdirectory, followed by a semicolon, which is
;

- Click OK until the Control Panel closes.
- Open a new console window, navigate to your test application, and type
javac HelloWorld.java
and remember, Java is
case-sensitive:
- Verify that the prompt returns with no message.
- Type dir *.class to see if the compile created
a file named HelloWorld.class
- Type java HelloWorld
and press Enter,
and remember, Java is case-sensitive.
- Verify that you see the output
"Hello World!"
Troubleshooting "class not found"
- IF
you get a message saying something like "class not found", you must
create or update your CLASSPATH environment variable to point to the
current directory. Follow the instructions for PATH, but this time
update or create a new variable call CLASSPATH and set its value to
.
that is a period (.) with nothing before or after the period.

- Close any open console window.
- Start a new console window, type
java HelloWorld
and press Enter,
and remember, Java is case-sensitive.
- Verify that you see the output
"Hello World!"
(Optional) Download Demos and Samples
- Go back to http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Download the JDK Demos and Samples, which will have a name like
jdk-7u4-windows-x64-demos.zip
-
Extract the zip to a directory where you want the demos.
- In my case, I extracted to
C:\first-course-in-java\demos\ so now I navigate to
C:\first-course-in-java\demos\jdk1.7.0_04\demo\applets\Fractal and launch
example1.html
- I am prompted to install a Plug-In to support a Java applet running
inside my HTML browser. In my case, the browser installed an earlier
version of the Java Runtime Environment, 1.6, so I now have two
different versions of the JRE. The 1.6 got installed into C:\Program Files
(x86)\Java\jre6 and I need to reboot my computer.
Apple Macintosh OS X
Use a Text Editor, not Notepad or Word
For this First Course in Java, we recommend that you write
your source code
using a text editor you like.
Some text editors feature "syntax highlighting", that is, color to
your source code to indicate the type (comments, keywords, strings,
brackets, numbers).
Some provide shortcut keys that make it easier to compile and run a
command-line application.
- TextPad:
http://www.textpad.com
($32, easy to use, with useful features for this course)
- has a free trial version
- Includes integration with the Java
Development Kit. See the Textpad help topic "How to Use with the Java
Development Kit"
- Notepad++
(free
with good features) -
http://notepad-plus.sourceforge.net/uk/site.htm
- UltraEdit-32:
http://www.ultraedit.com/
($50: with more features - more than is needed for this
class)
- JEdit, a text editor written in
Java: http://sourceforge.net/projects/jedit/
and perhaps a good choice for Mac users
- The following lack
essential features of a Java editor and are NOT recommended:
- Notepad - no color coding (free with Windows, but not
the best choice for learning Java)
- Word--save as text - (free with Windows, but not the
best choice for learning Java)
- vi or emacs
(UNIX)
- SimpleText (Mac)
Integrated development environments (IDEs)
with sophisticated features are good for developing large, enterprise
level applications involving many developers, but I do NOT recommend
them for the first course because gaining familiarity with a new tool
costs time, can distract the student from the fundamental language
concepts, and can complicate the submission of your homework by email.
I list some IDEs
for your information but do NOT support your use of them for this course.
File System Navigation Commands, such as dir and cd ..
DOS-style commands often used at the command line:
- cd\ changes
directory to the system root
- cd ..
changes directory up one level
- dir
prints to the screen the files (and directories) visible at that level
More commands are listed at
http://www.computerhope.com/msdos.htm#02
About the instructor
Thomas Albert has
taught First Course in
Java for the following terms:
- Summer 2012 (EDP 154286)
- Spring 2012 (EDP 303776)
- Fall 2011 (EDP 311100)
- Summer 2011 (EDP 315440)
- Spring 2011 (EDP 306936)
- Fall 2010 (EDP 318063)
- Summer 2010 (EDP 304147)
- Spring 2010 (EDP 3235834)
- Fall 2009 (EDP 311944)
- Summer 2009 (EDP 305375)
- Fall 2008 (EDP 318402)
- Spring 2007 (EDP 306969)
- Summer 2006 (EDP 304758)
- Fall 2005 (EDP 321299)
- Summer 2005 (EDP 305789)
- Spring 2005 (EDP 126581)
- Fall 2004 (EDP 128645)
- Summer 2004(EDP 124115)
- Spring 2004 (EDP 123158)
- Summer 2003 (EDP 135277)
- Spring 2003 (EDP 306704)
He is Advisory Technical Writer for Software Developer
Documentation
at Accelrys, a global firm that serves the biotech and
pharmaceutical research industries with Java-based middleware, .NET and web-based electronic
laboratory notebooks, and chemical databases.
He writes sample code, syntax reference, and developer guide
documentation
involving Java, .NET, and the Cheshire
scripting language for chemical structure database normalization.
He has 18 years experience in publishing technical information about
software
and 13 years experience teaching at the college level.
He holds a UC Berkeley Extension Certificate in Computer Information
Systems, a
doctoral degree in English, and a bachelors
degree
(with High Honors) in Political Science from U.C. Berkeley.
For more information, see http://www.WORDesign.com
last updated: 2012-JUNE-05
Copyright © 2002 - 2012 granted to the Regents of the University
of California