You are on page 1of 4

Lesson 1: Introduction to Programming

I. Brief history of Java Programming Language


Java, having been developed in 1991, is a relatively new programming language. At that time,
James Gosling from Sun Microsystems and his team began designing the first version of Java
aimed at programming home appliances which are controlled by a wide variety of computer
processors.

Gosling's new language needed to be accessible by a variety of computer processors. In 1994,


he realized that such a language would be ideal for use with web browsers and Java's
connection to the internet began. In 1995, Netscape Incorporated released its latest version of
the Netscape browser which was capable of running Java programs.

Why is it called Java? It is customary for the creator of a programming language to name the
language anything he/she chooses. The original name of this language was Oak, until it was
discovered that a programming language already existed that was named Oak. As the story
goes, after many hours of trying to come up with a new name, the development team went out
for coffee and the name Java was born.

II. Terminologies:
a. Computer Program – a sequence of statements intended to accomplish a task.
b. Programming – process of planning and creating a program.
c. Programming Language – set of rules, symbols, and special words used to construct
programs.
d. Class – used to create Java programs. It is used to group a set of related operations.
e. Method – a Java mechanism where operations in a program is implemented.
f. Identifier – names of things, such as variables, constants and methods, that appear in
programs.
g. Variable– memory cells whose contents can be modified during program execution.
h. Declaration – declare things such as variable; naming and identifying the data type of a
variable.
i. Initialization – placing for the first time the value of a variable.
j. Debugging – removing the errors in a program.
k. Reserved Wordsare names that cannot be used for anything other than their intended
use. (Example:int, double, char, boolean etc.)
l. Method – a Java mechanism where operations in a program is implemented. Used to
divide complicated programs into manageable pieces.
m. Unified Modeling Language (UML)–a graphical representation of a class and its
members.
n. Parameters – used to provide information to a subroutine when that subroutine is
called.
o. Predefined Methods – methods that are readily available in Java.
p. User-defined Methods – methods that are created by a programmer.

New Era University


Computer Programming 2 Page 1
Lesson 1: Introduction to Programming

q. Value-returning methods – methods that have a return data type. These methods return
a value of a specific data type using the return statement.
r. Void methods – methods that do not have return type. These methods do not use a
return statement to return a value.
s. Method overloading – several methods with the same name within a class but must
have different formal parameter list.
t. Array– a collection (sequence) of a fixed number of variables called elements or
components wherein all elements are of the same data type.
u. Index – specifies the position of an element in an array.
v. Base address—the address (memory location) of the first array element.
w. Array subscripting operator– represented by [] symbol. Used in array to access a specific
element coupled with an index.
x. Out of Bounds – if the index used is greater than array size minus 1 (size - 1).

III. Rules in naming Java variables


a. Variable names are case-sensitive. A variable's name can be any legal identifier — an
unlimited-length sequence of Unicode letters and digits, beginning with a letter, the
dollar sign "$", or the underscore character "_". The convention, however, is to always
begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign
character, by convention, is never used at all. You may find some situations where auto-
generated names will contain the dollar sign, but your variable names should always
avoid using it. A similar convention exists for the underscore character; while it's
technically legal to begin your variable's name with "_", this practice is discouraged.
White space is not permitted.
b. Subsequent characters may be letters, digits, dollar signs, or underscore characters.
Conventions (and common sense) apply to this rule as well. When choosing a name for
your variables, use full words instead of cryptic abbreviations. Doing so will make your
code easier to read and understand. In many cases it will also make your code self-
documenting; fields named cadence, speed, and gear, for example, are much more
intuitive than abbreviated versions, such as s, c, and g. Also keep in mind that the name
you choose must not be a keyword or reserved word.
c. If the name you choose consists of only one word, spell that word in all lowercase
letters. If it consists of more than one word, capitalize the first letter of each subsequent
word. The names gearRatio and currentGear are prime examples of this convention. If
your variable stores a constant value, such as static final int NUM_GEARS = 6, the
convention changes slightly, capitalizing every letter and separating subsequent words
with the underscore character. By convention, the underscore character is never used
elsewhere. (Camelized)

IV. Java Primitive Data Types


a. char (16 bits)

New Era University


Computer Programming 2 Page 2
Lesson 1: Introduction to Programming

b. byte (8 bits)
c. short (16 bits)
d. int (32 bits)
e. long (64 bits)
f. boolean (true or false)
g. float (6 or 7 decimal points)
h. double (15 decimal points)

V. Input and Output


a. Output
i. System.out.print();
ii. System.out.println();
iii. BufferedWriter
b. Input
i. BufferedReader
ii. Scanner Class
1. Code:
importjava.util.*;
Scanner console = new Scanner (System.in);
console.next();nextLine(); nextInt(); nextDouble();

VI. Control Structures


Provide alternatives to sequential program execution and are used to alter the flow of
execution.
a. Selection – the program executes particular statements depending on one or more
conditions.
b. Repetition – the program repeats particular statements a certain number of times
depending on one or more conditions.

VII. String Manipulation

New Era University


Computer Programming 2 Page 3
Lesson 1: Introduction to Programming

New Era University


Computer Programming 2 Page 4

You might also like