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

Schedule

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

Syllabus

Textbook (required)


5th Edition (2011) or 4th Edition (2007)

by Herbert Schildt
McGraw Hill/Osborne
540 pages.
Its code samples are at http://www.mhprofessional.com/getpage.php?c=oraclepress_downloads.php&cat=4222 and a PDF of the first chapter is at http://www.mhprofessional.com/downloads/products/0071606327/01-ch01_6327.pdf

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

bDavid 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


Course Description 

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.


Grading Policy

Criteria for Grading the Homework

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.


Submitting Homework and Quiz

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:

  • a comment header that:

    • identifies you

    • details any usage instructions necessary to run the program

    • provides sample output

  • your source code and comments

The header comment should follow this format:

Email Address, Deadline, and Late Penalty

How to copy output from the DOS window:

  1. Click the icon for the command prompt, which is in the top left corner. A menu appears.
  2. Select Edit > Mark
  3. Drag your cursor over the characters that you want to mark for saving. This selects the text.
  4. To copy the text to the clipboard, press the Enter key.
  5. Paste the text in your source code file.
  6. 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,

  1. 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.
  2. Go to http://java.sun.com/ or more, precisely, http://www.oracle.com/technetwork/java/javase/downloads/index.html
  3. Under Java Platform, Standard Edition, click the JDK (not JRE) Download button.
  4. Accept the License Agreement.
  5. Select your operating system, such as Windows x64.
    XP is 32-bit, but most installations of Windows 7 are 64-bit.
  6. 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
  7. Navigate to the directory to which you downloaded the installer.
  8. Launch the installer application.
  9. Grant permission for the installer to run.
  10. Follow the instructions of the installation wizard.
  11. Note the directory in which the JDK is being installed. The default location might be C:\Program Files\Java\jdk1.7.0_04\
  12. 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)
  13. 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)
  14. 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
  15. Verify that C:\Program Files\Java\jdk1.7.0_04\bin contains javac.exe, the compiler, and java.exe, the interpreter.
  16. Write down the exact path to the directory with the compiler and interpreter.
  17. 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!");
      }
    }

  18. 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

  1. 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.
  2. Close this console.
  3. Remember the path, which might be C:\Program Files\Java\jdk1.7.0_04\bin
  4. Go to Start > Control Panel > System > Advanced.
  5. Click Environment Variables.
  6. Under System Variables, select PATH and click Edit.
  7. 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 ;
  8. Click OK until the Control Panel closes.
  9. Open a new console window, navigate to your test application, and type javac HelloWorld.java
    and remember, Java is case-sensitive:
  10. Verify that the prompt returns with no message.
  11. Type dir *.class to see if the compile created a file named HelloWorld.class
  12. Type java HelloWorld and press Enter,
    and remember, Java is case-sensitive.
  13. Verify that you see the output "Hello World!"

Troubleshooting "class not found"

  1. 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.
  2. Close any open console window.
  3. Start a new console window, type java HelloWorld and press Enter,
    and remember, Java is case-sensitive.
  4. Verify that you see the output "Hello World!"

(Optional)  Download Demos and Samples

  1. Go back to http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Download the JDK Demos and Samples, which will have a name like jdk-7u4-windows-x64-demos.zip
  3. Extract the zip to a directory where you want the demos.
  4. 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
  5. 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

The Java SDK is preconfigured on Mac OS X but users need to download a text editor, such as TextWrangler - http://www.barebones.com/products/textwrangler/download.html

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.

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:

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:

  1. Summer 2012 (EDP 154286)
  2. Spring 2012 (EDP 303776)
  3. Fall 2011 (EDP 311100)
  4. Summer 2011 (EDP 315440)
  5. Spring 2011 (EDP 306936)
  6. Fall 2010 (EDP 318063)
  7. Summer 2010 (EDP 304147)
  8. Spring 2010 (EDP 3235834)
  9. Fall 2009 (EDP 311944)
  10. Summer 2009 (EDP 305375)
  11. Fall 2008 (EDP 318402)
  12. Spring 2007 (EDP 306969)
  13. Summer 2006 (EDP 304758)
  14. Fall 2005 (EDP 321299)
  15. Summer 2005 (EDP 305789)
  16. Spring 2005 (EDP 126581)
  17. Fall 2004 (EDP 128645)
  18. Summer 2004(EDP 124115)
  19. Spring 2004 (EDP 123158)
  20. Summer 2003 (EDP 135277)
  21. 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