CIS163AA - Java Prog I - Sect 5811 - Worksheet #1 - by Pat Moss
Due Monday, September 12, 2005
Name: Pat Moss
I. Definitions: Please explain the following terms:
1. software -- Computer programs. Originates as high-level language,
(p. 39) such as Java, C++, Pascal, VB .NET, C#.
A compiler translates into object code for target CPU
or an interpreter executes one statement at a time.
The Java compiler generates CPU-independent byte code.
2. white space -- Consists of blanks, tabs, and newline characters.
(p. 33) Used to separate words and symbols (i.e., "tokens")
used in a Java program.
3. literal -- An explicit data value used in a program, such as
(p. 75) integers, floating point, character, and boolean.
4. class -- A class is the model or blueprint from which an object
(p. 46) is created.
5. method -- A method is a group of programming statements that is
(p. 46) given a name. A set of methods is associated with an
object. (a.k.a. function)
6. encapsulated -- The characteristic of an object that limits access
(p. 646) to the variables and methods contained within it.
7. primitive data type -- A data type that is predefined in a
(p. 656) programming language. In Java, we have
byte, short, int, long, float, double,
char, and boolean.
8. class library -- A set of classes that define useful services for
(p. 643) a programmer.
9. reserved word -- A word that has special meaning in a programming
(p. 658) language and cannot be used for any other purpose.
10. call a method -- Either the main program, or another method, can
(p. 166) pass control (i.e., can execute) another method.
This is known as "calling a method". Control is
returned to the next statement in the calling
code.
II. Question or short essay
1. What is the difference between a high level language and a low level
language? (p. 37)
a. A high level language is "people oriented", such as
the assignment statement A = B + C.
b. A low level language is "object computer oriented",
such as the binary instructions understood by a CPU.
2. What are two ways to include comments in a program? (p. 29)
a. Line comments -- Precede with "//".
b. Block comments -- Begin with "/*" and end with "*/".
Why include comments?
Comments are a form of documentation, to explain what a section of
program code "does", in order to help the originating programmer,
as well as other programmers, to understand the code.
3. What are the syntax rules for creating identifier names for a
program's identifiers? (p. 31)
An identifier that we make up for use in a program:
a. Must not begin with a digit, 0-9.
b. Continue with any combination of a-z, A-Z, 0-9, _ and $.
c. An identifier can be "any length" (less than infinite??).
d. An identifier must be "unique" within the local scope of a block.
e. An identifier must not be a "reserved word".
f. An identifier should be descriptive.
4. What is the difference between Java applets and Java applications?
a. A Java application contains "public static void main (String[] args)".
b. A Java application executes in a target environment, on a target CPU,
as an independent process.
c. A Java applet executes in a browser environment, as a dependent
process. (p. 96)
5. What are widening conversions?
a. When we assign a variable with less precision to a variable with
greater precision, this is called "widening". Since the target
variable is "larger", it can hold all of the information in the
source variable (such as storing an int value into a long).
Why should narrowing conversions be avoided?
b. When we assign a variable with greater precision to a variable
with less precision, this is called "narrowing". Since the target
variable is "smaller", it may not be able to hold all of the
information that is contained in the source variable (such as
storing a long value into an int), and precision may be lost.
III. Programming Exercises
Write source code for the following:
Write an application that prints your initials in large block letters.
Make each letter by printing out a sequence of the corresponding
regular characters. Hand in a printed copy of your source code.