2nd Quart Lesson 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Pasig Catholic College PCC @ 108: “Bringing the Good News to All Faith

Junior High School All Seasons Amidst Challenging Times”


SY 2020 – 2021
________________________________________________________________________________________________________________
Lesson One: Introduction to JAVA
Objective/s: Know the development and determine the functionality of JAVA programming
language.
__________________________________________________________________________________________________
LECTURE
Programming languages enable humans to write instructions that a computer can perform. With
precise instructions, computers coordinate applications and systems that run the modern world.

Java is an object-oriented programming language developed by James Gosling and


colleagues at Sun Microsystems in the early 1990s.

Sun Microsystems released the Java programming language in 1995. Java is known for being simple,
portable, secure, and robust. Though it was released over twenty years ago, Java remains one of the
most popular programming languages today.

One reason people love Java is the Java Virtual Machine, which ensures the same Java code can
be run on different operating systems and platforms. Sun Microsystems’ slogan for Java was “write
once, run everywhere”.
Programming languages
are composed of syntax, the specific
instructions which Java understands. We
write syntax in files to create programs,
which are executed by the computer to
perform the desired task.

It is used for:

• Mobile applications (especially


Android apps)
• Desktop applications
• Web applications
• Web servers and application
servers
• Games
• Database connection
• And much, much more!

Second Quarter Module for Grade 9 Prepared by Mr. John Allan Clave
Mrs. Celine Anne Dormiendo
Pasig Catholic College PCC @ 108: “Bringing the Good News to All Faith
Junior High School All Seasons Amidst Challenging Times”
SY 2020 – 2021
________________________________________________________________________________________________________________
The way Java works

Features of Java

1. Simple, object-oriented and familiar


- It can be programmed without extensive programmer training.
2. Robust and secure
- It is designed to operate in distributed environments which means that security is of
paramount importance.
3. High-performance
- The automatic garbage collector runs as a low-priority background thread, ensuring a
high probability that memory is available when required.
4. Interpreted, threaded and dynamic
- It can execute Java bytecodes directly on any machine to which the interpreter and
run-time system have been ported.
5. Architecture neutral and portable
- It is designed to support applications that will be deployed into heterogeneous network
environments.
- The Java Compiler product generates bytecodes – an architecture neutral
intermediate format designed to transport code efficiently to multiple hardware and
software platforms.

Why Use Java?


• Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
• It is one of the most popular programming languages in the world
• It is easy to learn and simple to use
• It is open-source and free
• It is secure, fast and powerful
• It has a huge community support (tens of millions of developers)
• Java is an object-oriented language which gives a clear structure to programs and allows
code to be reused, lowering development costs
• As Java is close to C++ and C#, it makes it easy for programmers to switch to Java or vice
versa

Second Quarter Module for Grade 9 Prepared by Mr. John Allan Clave
Mrs. Celine Anne Dormiendo
Pasig Catholic College PCC @ 108: “Bringing the Good News to All Faith
Junior High School All Seasons Amidst Challenging Times”
SY 2020 – 2021
________________________________________________________________________________________________________________

Lesson Two: Java Syntax


Objective/s: Know the development and determine the functionality of JAVA programming
language.
__________________________________________________________________________________________________

LECTURE

Creating Hello Java!

To create a simple java program, you need to create a class that contains the main method.

Understanding the Hello Java Program

• Comments are statements that are not executed by the compiler and interpreter. The
comments can be used to provide information or explanation about the variable, method,
class or any statement. It can also be used to hide program code for specific time.

➢ Single-line comment start with two forward slashes (//).


Any text between // and the end of the line is ignored by Java (will not be
executed).
➢ Multi-line comments start with /* and ends with */. Any text
between /* and */ will be ignored by Java.

• HelloJava is the Class name of the program above. Every line of code that runs in Java must
be inside a class. In our example, we named the class HelloJava. A class should always start
with an uppercase first letter. The name of the java file must match the class name. When
saving the file, save it using the class name and add ".java" to the end of the filename.

Note: Java is case-sensitive: "HelloJava" and "hellojava" has different meaning.

• The main()method is required and you will see it in every Java program:

➢ Example public static void main(String[] args)

Any code inside the main() method will be executed. Every Java program has a class name
which must match the filename, and that every program must contain the main() method.

• The second line of the program consists of the left brace, which is matched with the second
right brace (the very last brace). These braces together mark the beginning and end of (the
body of) the class HelloJava.

Second Quarter Module for Grade 9 Prepared by Mr. John Allan Clave
Mrs. Celine Anne Dormiendo
Pasig Catholic College PCC @ 108: “Bringing the Good News to All Faith
Junior High School All Seasons Amidst Challenging Times”
SY 2020 – 2021
________________________________________________________________________________________________________________

System.out.println or Sop is used to print specific data or value.


Types of Sop

➢ System.out.print(); is used to print the data within the line.


➢ System.out.println(); is used to print the next data in the next line.

• The line System.out.println("Hello World!");prints the characters between quotes to the


console.

Note: The curly braces { } marks the beginning and the end of a block of code.
Note: Each code statement must end with a semicolon.

Java Terminologies:

o class keyword is used to declare a class in java.


o public keyword is an access modifier which represents visibility, it means it is visible to all.
o static is a keyword, if we declare any method as static, it is known as static method. The core
advantage of static method is that there is no need to create object to invoke the static
method.
o void is the return type of the method, it means it doesn't return any value.
o main represents startup of the program.
o String[] args is used for command line argument.
o System.out.println() is used print statement.

Example of Simple Java Program

Java program with the class name of SampleProgram

PROGRAM

public class SampleProgram


{
public static void main(String[] args) {
System.out.println("Good Day");
OUTPUT
System.out.print("Praise Be");
System.out.println(" Jesus Christ!");
Good Day
System.out.print("Now ");
System.out.print("and ");
Praise Be Jesus Christ!
System.out.print("forever ");
Now and forever
}
}

Second Quarter Module for Grade 9 Prepared by Mr. John Allan Clave
Mrs. Celine Anne Dormiendo

You might also like