0% found this document useful (0 votes)
2 views

Chapter-I-Java-Runtime-Environment-and-its-Component

The document provides an introduction to Java programming, focusing on the Java Virtual Machine (JVM) and its role in enabling platform independence. It covers the creation of simple Java applications, the significance of bytecode, and the structure of Java programs including methods and classes. Additionally, it discusses algorithms, their representation through pseudocode and flowcharts, and includes laboratory activities for practical application.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Chapter-I-Java-Runtime-Environment-and-its-Component

The document provides an introduction to Java programming, focusing on the Java Virtual Machine (JVM) and its role in enabling platform independence. It covers the creation of simple Java applications, the significance of bytecode, and the structure of Java programs including methods and classes. Additionally, it discusses algorithms, their representation through pseudocode and flowcharts, and includes laboratory activities for practical application.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

CHAPTER I

JAVA
RUNTIME
ENVIRONMENComputer
Fundamentals and Programming
CHAPTER I

OVER
a) Java Virtual Machine

VIEW
b) Creating a Simple, Stand-Alone
Application and Applet
c) Java Comments
d) Features of Java Programs
e) Algorithms
CHAPTER I

INTRO
The Java Virtual Machine (JVM) separates Java from most other

DUCTI
programming languages.

One of the primary design goals of the Java language is to enable the
same code to run on any platform.

ON
The JVM is a software program that behaves like an entire computer.
CHAPTER I

CREATING A SIMPLE,
STAND-ALONE
Give the class a name and a
pair of braces to contain the

APPLICATION
body of the class.

By convention, the class name


should start with a capital
letter as in the following
example:
CHAPTER I

CREATING A SIMPLE,
STAND-ALONE
To begin executing code, the
JVM looks for and calls a
special method by the name
APPLICATION
of public static void
main(String[] args).

The JVM uses this method to


begin executing your
program
CHAPTER I

CREATING A SIMPLE,
STAND-ALONE
This program is complete. Note that Java programs are case-
sensitive; the word Class is not the same as class.

APPLICATION
You must save the program with your text editor as HelloWorld.java
(giving it the same name as your class), and compile it using a Java
compiler
CHAPTER I

CREATING A SIMPLE,
STAND-ALONE
Bytecode is another element that makes Java different from other
programming languages.

APPLICATION
Other compiled programming languages generate machine
dependent binaries, which are files that contain native machine
language statements. To make Java portable, the Javac compiler
generates bytecode. Java bytecode is composed of an instruction set
native only to the JVM.
CHAPTER I

CREATING A SIMPLE,
STAND-ALONE
To make Java portable, the Javac compiler generates bytecode. Java
bytecode is composed of an instruction set native only to the JVM.

APPLICATION
CHAPTER I

JAVA COMMENTS
When programming, it will be
useful to add comments to
your code.

Java supports three types of


comments; two will be
recognizable to those familiar
with C or C++, and the third
type is unique to Java.
CHAPTER I

FEATURES OF JAVA
PROGRAMS
A method is a named sequence of statements. This program defines
one method named main:

public static void main(String[] args) The name and format of main is
special: when the program runs, it starts at the first statement in
main (All java programs begin here) and ends when it finishes the
last statement.
CHAPTER I

FEATURES OF JAVA
PROGRAMS
A class is a collection of methods. In this program defines a class
named MyFirstJava. The name of the class has to match the name of
the file it is in, so this class has to be in a file named MyFirstJava.java.

Java uses curly braces ({ and }) to group things together. In


MyFirstJava.java, the outermost braces contain the class definition,
and the inner braces contain the method definition.
CHAPTER I

ALGORITHMS
An algorithm specifies a series of steps that perform a particular
computation or task.

Algorithms were originally born as part of mathematics - the word


"algorithm" comes from the writer Muhammad ibn Musa-al-Khwarizmi -
but currently the word is associated with computer science.

In programming, each step should be clear and defined precisely to solve


a particular problem most effectively
CHAPTER I

ALGORITHMS
Write an algorithm to add two numbers entered by user:

Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to
sum. sum←num1+num2
Step 5: Display sum
Step 6: Stop
CHAPTER I

ALGORITHMS
There are two ways of presenting an algorithm.

One way is by a flowchart and another way is to write it in


pseudocode language.
CHAPTER I

ALGORITHMS
Flowcharts use special shapes to represent different types
of actions or steps in a process.

Lines and arrows show the sequence of the steps, and the
relationships among them.
CHAPTER I

ALGORITHMS
These are known as flowchart symbols.
1. Rectangle Shape - Represents a process
2. Oval or Pill Shape - Represents the start or end
3. Diamond Shape - Represents a decision
4. Parallelogram - Represents input/output
CHAPTER I

ALGORITHMS
CHAPTER I

ALGORITHMS
CHAPTER I

Problem
Specification

PROG Coding, Testing,


Debugging, and
Problem
Decomposition
Revising Java

RAM
DEVE
LOPM Data, Method
and Algorithm
Design
Class Design
CHAPTER I

LABORATORY
ACTIVITY #1:
Formulate at least (3) pseudocodes of a Java Program, you
may use the example from the discussion earlier.

PSEUDO-CHARTS
After accomplishing your pseudos, create a flowchart as
well.

Accomplish in a 1 whole sheet of yellow pad paper,


minimize erasures as much as possible.
CHAPTER I

LABORATORY
ACTIVITY #2: ALL Full name:
Nickname:

ABOUT YOU!
Based on the discussion and
fundamental parts of a Java program,
create your first Java program
Age:
Gender:
Birthday:
indicating the following Birthplace:
demographics about yourself: Current Address:
Currently studying (Bachelor’s
Degree, full):

You might also like