Introduction to Java
for New Programmers
Robert J. Oberg
Student Guide
Revision 1.1
Copyright © 2000 Object Innovations, Inc.
All Rights Reserved
Introduction to Java for New Programmers
Student Guide
Information in this document is subject to change without notice. Companies, names and data
used in examples herein are fictitious unless otherwise noted. No part of this document may be
reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose, without the express written permission of Object Innovations.
Copyright ©2000 Object Innovations, Inc.. All rights reserved.
Object Innovations, Inc.
420 Boston Turnpike
Shrewsbury, MA 01545
(508) 845-1195
[Link]
Printed in the United States of America.
Java and Java Development Kit are trademarks of Sun Microsystems. Microsoft, Windows,
Windows NT, Windows 95, Windows 98, Microsoft Visual Studio and Microsoft Visual J++ are
either trademarks or registered trademarks of Microsoft Corporation in the United States of
America and other countries.
Acknowledgements
Object Innovations wishes to thank Jon Levinson for his contribution of the
InputWrapper class used throughout the course. This concise code elegantly overcomes a hurdle
for the beginning Java programmer: how to do interactive input.
Rev. 1.1 Copyright © 2000 Object Innovations, Inc. ii
All Rights Reserved
Table of Contents
Course Objectives and Approach
Prerequisites and Labs
Hands-on Directory Structure
Chapter 0 Introduction to Computers
Chapter 1 What is Java?
Chapter 2 First Java Programs
Chapter 3 Data Types and Operators
Chapter 4 Logical and Bit Operations
Chapter 5 Loops and Structured Programming
Chapter 6 Introduction to Objects
Chapter 7 Objects and Classes
Chapter 8 Characters and Strings
Chapter 9 Modular Programming
Chapter 10 Arrays
Chapter 11 Algorithms and Problem Solving
Chapter 12 Control Structures and Exceptions
Appendix A Learning Resources
Appendix B The Electronic Commerce Game
Appendix C Using Visual J++ and Visual Studio
Rev. 1.1 Copyright © 2000 Object Innovations, Inc. iii
All Rights Reserved
Course Objectives and Approach
• The course is an introduction to object oriented
programming using Java
• Programming is taught from the ground up
• Java is used as the language because of its growing
importance in modern application development
− Core syntax of Java is very similar to C and C++, so you will
receive a good grounding for subsequent study of these
languages as well
• An important thrust of the course is to teach
programming from an object oriented perspective
− It is often difficult for programmers trained in procedural
languages to start “thinking in objects”
− Object are introduced early in the course first at the
conceptual level and then at the programming level
− A major case study is used to illustrate object oriented
programming techniques, including the initial analysis and
design
Rev. 1.1 Copyright © 2000 Object Innovations, Inc. iv
All Rights Reserved
Prerequisites and Labs
• Prerequisites:
− Good general problem solving skills
− User experience on a PC would be helpful
• Although intended for beginning programmers, you
may find this course beneficial if you have experience
in a procedural language and wish to learn object
oriented programming
• Extensive labs are an integral part of the course
− An attempt is made to minimize the amount of coding,
emphasizing concepts, but significant coding is required for
some labs
− Detailed step by step instructions are provided for each lab
along with answers. The answers are there for you to use -- it
is not "cheating" to look at them to help understand the lab!
− Many labs deal with the Electronic Commerce Game case
study
Rev. 1.1 Copyright © 2000 Object Innovations, Inc. v
All Rights Reserved
Hands-On Directory Structure
• Top-level directory INTROJAVA, with
subdirectories LABS, EXAMPLES, DEMOS and
PROJECT
• LABS has named subdirectories for doing lab work
− The location of answers is specified in each lab
• EXAMPLES has named subdirectories containing
various example programs
− Some of the examples have multiple steps, and some of the
lab exercises involve implementing steps of these examples
• DEMOS is provided for hands-on work during
lectures
• PROJECT contains all files pertaining to the
Electronic Commerce Game case study
− CLASS contains executable version you can run
− GAME contains all the source code
− WORK is where you will do all your work implementing
your own version of the game
− Additional subdirectories contain starter code and unit tests
for portions of the project
Rev. 1.1 Copyright © 2000 Object Innovations, Inc. vi
All Rights Reserved