




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
It tackles about the history of the Philippines. Where it started and
Typology: Slides
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Fundamentals of Programming
Module 1
DESCRIPTION : Fundamentals of Programming
This module opens the minds of the students about the realities and technicalities of using Java language. It discusses
what Java language is all about, how to install it, the parts of every Java program, and how to create and run a Java
program using Eclipse®.
After the students read this module, they should be able to:
History of Java
James Gosling ➔ Initiated Java language project in June 1991.
Sun Microsystems ➔ released the first public implementation as Java 1.0 in 1995.
November 13, 2006 ➔ Sun released much of Java as free and open source software under the terms of the GNU
General Public License (GPL).
May 8, 2007 ➔ Sun finished the process, making all of Java’s core code free and open-source.
Characteristics of Java:
Java program, it can be executed to any operating systems.
to master.
techniques are based on public-key encryption.
Fundamentals of Programming
Module 1
Object ➔ is an instance or a member of a class.
Class ➔ can be defined as a template/blueprint that describes the behaviors/states that object of its type support.
Methods ➔ is basically a behavior. A class can contains many methods. It is in methods where the logics are written,
data is manipulated and all the actions are executed.
Instance variables ➔ each object has unique set of instance variables. An object’s state is created by the values assigned
to these instance variables.
What you will need?
Note: you can use any other text editors (ex. Notepad, NetBeans, etc.) but using notepad would be very difficult to make
a program. You need to remember the syntax of it and if there are any issues, you need to identify them by your own.
What will appear?
Select Workspace ➔ it is the area wherein your programs will be created.
Note : For the students, you are required to create your own workspace on your Flash Drive/Computer. To do that,
create a folder in your flash drive/Computer and name it starting with Your Surname + Java Programs (Ex. Guirigay Java
Programs). That folder would serve as your permanent workspace.
Welcome screen ➔ gives you choices on what you are going to do.
Note : you can select any of the choices or you can close the welcome screen to make the Eclipse IDE appear.
Fundamentals of Programming
Module 1
Explanations:
Line 2 defines a class. Every Java program must have at least one class. Each class has a name. By convention, class
names start with an uppercase letter. In this example, the class name is DisplayingText.
Line 3 defines the main method. The program is executed from the main method. A class may contain several methods.
The main method is the entry point where the program begins execution.
A method is a construct that contains statements. The main method in this program contains the
System.out.println statement. This statement displays the string Welcome to Java! on the console (line 6 ). String is
a programming term meaning a sequence of characters. A string must be enclosed in double quotation marks. Every
statement in Java ends with a semicolon (;), known as the statement terminator.
Line 4 is a comment that documents what the program is and how it is constructed. Comments help programmers to
communicate and understand the program. They are not programming statements and thus are ignored by the
compiler.
Types of comments:
Single-line comments (represented by “//” symbols) ➔ is used when there is only one-line comment.
Multiple-line comments (represented by a pair of “/” and “/” symbols) ➔ is used when there is a block of line
(multiple-line) comments.
A pair of curly braces ({}) in a program forms a block that groups the program’s components. In Java, each block begins
with an opening brace ({) and ends with a closing brace (}).
Tip : An opening brace must be matched by a closing brace. Whenever you type an opening brace, immediately type a
closing brace to prevent the missing-brace error. Most Java IDEs automatically insert the closing brace for each opening
brace.
Character Name Description
{} Opening and Closing braces Denote a block to enclose statements.
() Opening and Closing parenthesis Used with methods.
[] Opening and Closing brackets Denote an array.
// Double Slashes Precede a comment line.
“” Opening and Closing quotation marks Enclose a string (i.e., sequence of characters
; Semicolon Mark the end of the statement.
Sample program # 2 : Displaying Multiple-line text
Code:
Fundamentals of Programming
Module 1
Output:
You can even compute mathematical computations and display the result on the console.
Sample Program # 3: Compute Expression
Output:
Single-line Comment ➔ represented by the symbols “//”
Multiple-line Comment ➔ represented by a pair of symbols “/* … */”
System.out.println(3+4*4); → Bad style
System.out.println(3 + 4 * 4); → Good style
Fundamentals of Programming
Module 1
public static void main(String[] args) {
System. out .println(1 / 0);
Output:
3. Logic Errors
Are errors that occur when a program does not perform the way it was intended to.
Sample Program: ShowLogicErrors.java
Output:
4. Common Errors - Missing Braces
The braces are used to denote a block in the program. Each opening brace must be matched
by a closing brace. A common error is missing the closing brace.
Each statement ends with a statement terminator (;). Often, a new programmer forgets to place
a statement terminator for the last statement in a block.
Missing Semi-colon
Fundamentals of Programming
Module 1
A string must be placed inside the quotation marks. Often, a new programmer forgets to place
a quotation mark at the end of a string.
Java is case sensitive. Misspelling names is a common error for new programmers. For example, the
word main is misspelled as Main and String is misspelled as string in the following code.
EVALUATION
REFERENCE
th
Edition); Pearson Education, Inc.,: 2015
th
Edition; Wiley Publishing Inc.,: 2011
th
Edition: Oracle America Inc.,: 2011
Missing quotation mark