Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

IT - 201 history Module 1, Slides of History

It tackles about the history of the Philippines. Where it started and

Typology: Slides

2022/2023

Uploaded on 11/06/2023

lanilyn-mongado
lanilyn-mongado 🇵🇭

3 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Fundamentals of Programming
1
Module 1
SUBJECT : IT 201
DESCRIPTION : Fundamentals of Programming
PREPARED BY : MR. ALEX B. GUIRIGAY
Module 1
TITLE: Introduction
OVERVIEW
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®.
OBJECTIVES
After the students read this module, they should be able to:
Understand the meaning of Java language specification, API, JDK, and IDE;
Write a simple Java program;
Display output on the console;
Explain the basic syntax of a Java program;
Create, compile, and run Java programs; and
Use sound Java programming style and document programs properly;
Explain the differences between syntax errors, runtime errors, and logic errors; and
Develop Java programs using Eclipse®.
DISCUSSION
FAQs
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:
Platform independent it has its tagline “Write once, run anywhere” which means once you have written your
Java program, it can be executed to any operating systems.
Object-oriented it embodies the modern, object-oriented programming philosophy.
Simple Java is designed to be easy to learn. If you understand the basic concept of OOP, Java would be easy
to master.
Secure with java’s secure feature, it enables to develop virus-free, tamper-free systems. Authentication
techniques are based on public-key encryption.
Multithread
Dynamic
pf3
pf4
pf5
pf8

Partial preview of the text

Download IT - 201 history Module 1 and more Slides History in PDF only on Docsity!

Fundamentals of Programming

Module 1

SUBJECT : IT 201

DESCRIPTION : Fundamentals of Programming

PREPARED BY : MR. ALEX B. GUIRIGAY

Module 1

TITLE: Introduction

OVERVIEW

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

OBJECTIVES

After the students read this module, they should be able to:

  • Understand the meaning of Java language specification, API, JDK, and IDE;
  • Write a simple Java program;
  • Display output on the console;
  • Explain the basic syntax of a Java program;
  • Create, compile, and run Java programs; and
  • Use sound Java programming style and document programs properly;
  • Explain the differences between syntax errors, runtime errors, and logic errors; and
  • Develop Java programs using Eclipse®.

DISCUSSION

FAQs

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:

  • Platform independent ➔ it has its tagline “ Write once, run anywhere ” which means once you have written your

Java program, it can be executed to any operating systems.

  • Object-oriented ➔ it embodies the modern, object-oriented programming philosophy.
  • Simple ➔ Java is designed to be easy to learn. If you understand the basic concept of OOP, Java would be easy

to master.

  • Secure ➔ with java’s secure feature, it enables to develop virus-free, tamper-free systems. Authentication

techniques are based on public-key encryption.

  • Multithread
  • Dynamic

Fundamentals of Programming

Module 1

Points to ponder

  • Case Sensitivity
  • Use camel case
  • Apply the naming convention
  • Method names should all be in lower case
  • File name and class name should be the same

Java Basic Syntax

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.

Installation

What you will need?

  • Windows 95/98/2000/XP/7/8/10, Linux or Mac OS
  • JDK (Java Development Kit) (Advisable is JDK 8)
  • Eclipse® (2021 version) IDE (Integrated Development Environment)

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.

Using Eclipse

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.

Steps in creating a program

  1. Create a project
    • Go to File → New → Project → Java (folder) → Java project → next
    • Type the name of the project → next → finish

Fundamentals of Programming

Module 1

Welcome to Java

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.

Special Characters Table

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:

package Module1;

public class WelcomeWithThreeMessages {

Fundamentals of Programming

Module 1

public static void main(String[] args) {

System. out .println("Programming is fun!");

System. out .println("Fundamentals First");

System. out .println("Problem Driven");

Output:

Programming is fun!

Fundamentals First

Problem Driven

You can even compute mathematical computations and display the result on the console.

Sample Program # 3: Compute Expression

package Module1;

public class ComputeExpression {

public static void main(String[] args) {

System. out .println((10.5 + 2 * 3) / (45 - 3.5));

Output:

Programming Style and Documentation

  1. Appropriate comments and comment styles

Single-line Comment ➔ represented by the symbols “//”

Multiple-line Comment ➔ represented by a pair of symbols “/* … */”

  1. Proper indentation and spacing

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:

Exception in thread "main" java.lang.ArithmeticException: / by zero

at Module1.ShowRuntimeErrors.main(ShowRuntimeErrors.java:6)

3. Logic Errors

 Are errors that occur when a program does not perform the way it was intended to.

Sample Program: ShowLogicErrors.java

package Module1;

public class ShowLogicErrors {

public static void main(String[] args) {

System. out .println("Celsius 35 is Fahrenheit degree ");

System. out .println((9 / 5) * 35 + 32);

Output:

Celsius 35 is Fahrenheit degree

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.

public static void main(String[] args) {

}  Type this closing brace right away to match the opening brace.

  • Missing Semicolons

Each statement ends with a statement terminator (;). Often, a new programmer forgets to place

a statement terminator for the last statement in a block.

public class WelcomeWithThreeMessages {

public static void main(String[] args) {

System. out .println("Programming is fun!")

Missing Semi-colon

Fundamentals of Programming

Module 1

System. out .println("Fundamentals First");

System. out .println("Problem Driven");

  • Missing Quotation Marks

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.

System. out .println("Fundamentals First);

  • Misspelling Names

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.

public class WelcomeWithThreeMessages {

public static void Main(String[] args) {

System. out .println("Programming is fun!")

System. out .println("Fundamentals First");

System. out .println("Problem Driven");

EVALUATION

REFERENCE

  1. Y. Daniel Liang: Intro to Java Programming, Comprehensive Version (

th

Edition); Pearson Education, Inc.,: 2015

  1. Barry Burd: Java for Dummies 5

th

Edition; Wiley Publishing Inc.,: 2011

  1. J. Gosling, et. Al.: The Java Language Specification Java SE 7

th

Edition: Oracle America Inc.,: 2011

Missing quotation mark