You are on page 1of 17

J/SHS

TLE/TVL-ICT(Computer Programming-
Java)
Activity Sheet Quarter 2 – LO 6
Apply Basics of Java Language

REGION VI – WESTERN VISAYAS


TLE/TVL- ICT (Computer Programming - Java)
Activity Sheet No. 6
First Edition, 2020

Published in the Philippines


By the Department of Education
Region 6 – Western Visayas

Republic Act 8293, section 176 states that: No copyright shall subsist in any
work of the Government of the Philippines. However, prior approval of the
government agency or office wherein the work is created shall be necessary for
exploitation of such work for profit. Such agency or office may, among other things,
impose as a condition the payment of royalties.

This Learning Activity Sheet is developed by DepEd Region 6 – Western


Visayas.

ALL RIGHTS RESERVED. No part of this learning resource may be


reproduced or transmitted in any form or by any means electronic or mechanical
without written permission from the DepEd Regional Office 6 – Western Visayas.

Development Team of TLE/TVL- ICT (Computer Programming - Java) Activity


Sheet

Writer: Ma. Louella B. Gavan


Reviewer/Editor:Edward E. Baña
Layout Artist:
Schools Division Quality Assurance Team:
Schubert Anthony C. Sialongo
Edward E. Baña
Allan B. Montenegto
Michelle P. Jordan
Division of Antique Management Team:
Felisa B. Beriong, CESO VI
Corazon C. Tingson
Gaudencio C. Riego, PhD
Schubert Anthony C. Sialongo
Edward E. Baña
Regional Management Team
Ma. Gemma M. Ledesma
Josilyn S. Solana
Elena P. Gonzaga
Donald T. Genine
April C. Velez
Abraham P. Imas

2
Introductory Message
Welcome to TLE/TVL- ICT (Computer Programming - Java)!

The Learning Activity Sheet is a product of the collaborative efforts of the


Schools Division of Antique and DepEd Regional Office VI - Western Visayas
through the Curriculum and Learning Management Division (CLMD). This is
developed to guide the learning facilitators (teachers, parents and responsible
adults) in helping the learners meet the standards set by the K to 12 Basic Education
Curriculum.

The Learning Activity Sheet is self-directed instructional materials aimed to


guide the learners in accomplishing activities at their own pace and time using the
contextualized resources in the community. This will also assist the learners in
acquiring the lifelong learning skills, knowledge and attitudes for productivity and
employment.

For learning facilitator:

The TLE/TVL- ICT (Computer Programming - Java) Activity Sheet will help
you facilitate the leaching-learning activities specified in each Most Essential
Learning Competency (MELC) with minimal or no face-to-face encounter between
you and learner. This will be made available to the learners with the references/links
to ease the independent learning.

For the learner:

The TLE/TVL- ICT (Computer Programming - Java) Activity Sheet is


developed to help you continue learning even if you are not in school. This learning
material provides you with meaningful and engaging activities for independent
learning. Being an active learner, carefully read and understand the instructions then
perform the activities and answer the assessments. This will be returned to your
facilitator on the agreed schedule.

3
Quarter 2, Week 6

Learning Activity Sheets (LAS) No. 6

Name of Learner:_____________________________________________________
Grade and Section:_________________________________Date: ______________

TLE/TVL- ICT (COMPUTER PROGRAMMING - JAVA) ACTIVITY SHEET


Apply Basics of Java Language

I. Learning Competency with Code


Apply Basics of Java Language-TLE_ICTJAVA1 1-12POAD-IIfi-29

a. Demonstrate knowledge of Java technology and Java


programming
b. Create executable Java applications in accordance with Java
framework
II. Background Information for Learners
How would the world be without computer programming and
coding?
Without them, surely, life is never the same. As computing
becomes part of almost every profession, the have become basic
literacies in this age of evolving technologies. Ever since the
invention of first programming languages, they have greatly evolved
over the past years and has morphed into a more complex system
capable of performing organized and systematic processes. Used to
develop programs, softwares and operating systems they have huge
impact in improving functionality and efficiency of services in
businesses, healthcare, schools and other fields.
How does this work? A clearly defined and distinct work phases
are used to design and create functional information systems which
are used across fields.
In this module, you will learn about Systems Development Life
Cycle. A little bit of Java history, technology and the different phases
that a Java program undergoes will also be discussed.

Java Technology
Systems Development Life Cycle
What is Systems Development Life Cycle?
The Systems Development Life Cycle (SDLC) is the process of
understanding how an information system (IS) can support

4
business needs, analyzing and designing the system, developing
and delivering it to the end‐users.
The SDLC is usually broken down to the following phases: Systems
Planning, Systems Analysis, Design Phase, System
Implementation and Systems Operations, Support and Security.

Systems Planning

Systems Analysis

Design Phase

System Implementation

Systems Operations

Support and Security

Figure 1. The SLDC Phases

PHASE 1: Systems Planning


The systems planning phase usually starts with a formal request
from end‐users, called a system request that describes problems or
desired changes in an information system or business process. At
the end of the investigation, the analyst prepares the preliminary
investigation report and makes recommendations.
PHASE 2: Systems Analysis
Systems analysis involves a detailed study of the existing system to
understand the proposed system, ensure that it will support
business requirements, and build a solid foundation for the systems
design phase. The systems requirements specification, which is an
overall design for the new system, is the end‐product of system
analysis phase.
Requirements Modelling
Requirements modelling involves fact‐finding to describe the
current system and determine the requirements for the new

5
system including its inputs, outputs, processes, performance,
and security.
Data and Process Modelling
Data and process modeling is the translation of data gathered into a
graphical representation the using traditional analysis techniques.

PHASE 3: Design Phase


Architecture design describes the hardware, software, and network
infrastructure that will be used. Interface design describes how the
user will interact with the system. It includes the user interface to
input screens, menus, buttons and the design of forms and reports.
Database and file specifications define exactly what data will be
stored and where they will be stored. Program design, which defines
the programs that need to be written and exactly what each program
will do. Pseudocode and flowcharting is a tool that you can use to
prepare your program design.

Pseudocode
Pseudocode is a compact and informal high‐level description of the
operating principle of a computer program or other algorithm. It uses
the structural conventions of a programming language, but is
intended for human reading rather than machine reading. It
allows the designer to focus on the logic of the algorithm without
being distracted by details of language syntax.
At the same time, the pseudocode needs to be complete. It describes
the entire logic of the algorithm so that implementation becomes a
rote mechanical task of translating line by line into source code.

Common Action Keywords


Several keywords are often used to indicate common input, output, a
nd processing operations.
Input: READ, OBTAIN, GET
Output: PRINT, DISPLAY, SHOW
Compute: COMPUTE, CALCULATE, DETERMINE
Initialize: SET, INIT
Add one: INCREMENT, BUMP
Binary choice on a given Boolean Condition
(IF, THEN, ELSE, and ENDIF)
The general form is:
IF condition THEN
sequence 1
ELSE
sequence 2

6
ENDIF
Example
IF HoursWorked > NormalMax THEN
Display overtime message
ELSE
Display regular time message
ENDIF
WHILE
The WHILE construct is used to specify a loop with a test at the top.
The beginning and ending of the loop are indicatedby twokeywords
WHILE and ENDWHILE. The general form is:
WHILE condition
sequence
ENDWHILE
The loop is entered only if the condition is true. The "sequence" is per
formedfor each iteration. At the conclusion of each iteration, the
condition is evaluated and the loop continues as long as the
condition is true.
CASE
A CASE construct indicates a multi‐way branch based on conditions
that are mutually exclusive. Four keywords, CASE,OF,OTHERS, and
ENDCASE, and conditions are used to indicate the various
alternatives. The general form is:
CASE expression OF
condition 1 : sequence 1
condition 2 : sequence 2
...
condition n : sequence n
OTHERS:
default sequence
ENDCASE
The OTHERS clause with its default sequence is optional.
Conditions are
normally numbers or characters indicating thevalue of "expression",
but they can be English statements or some other notation that spec
ifies the condition under which the given sequence is to be
performed. A certain sequence may be associated
with more than one condition.
Example:
CASE Title OF
Mr : Print "Mister"
Mrs : Print "Missus"
Miss : Print "Miss"

7
Ms : Print "Mizz"
Dr : Print "Doctor"
ENDCASE
Example:
CASE grade OF
A : points = 0
B : points = 1
C : points = 2
D : points = 3
F : points = 4
ENDCASE
REPEAT‐UNTIL
This loop is similar to the WHILE loop except that the test is perform
ed at the bottom of the loop instead of at the top. Two keywords,
REPEAT and UNTIL are used. The general form is:
REPEAT
sequence
UNTIL condition
The "sequence" in this type of loop is always performed at least once,
because the test is performed after the sequence is executed. At the
conclusion of each iteration, the condition is evaluated, and the loop
repeats if the condition is false. The loop terminates when the
condition becomes true.
FOR
This loop is a specialized construct for iterating a specific number of
times, often called a "counting" loop. Two keywords, FOR and
ENDFOR are used. The general form is:
FOR iteration bounds
sequence
ENDFOR

In cases where the loop constraints can be obviously inferred it is


best to describe the loop using problem domain vocabulary.
Example:
FOR each month of the year (good)
FOR each faculty in the list (good)
FOR year = 1991 to 2011 (ok)

Flow Charting
The flowchart is a means of visually presenting the flow of data
through an information processing systems, the operations
performed within the system and the sequence in which they are
performed. The program flow chart can be likened to the blueprintof

8
a building. As we know a designer draws a blueprint
beforestartingconstruction on a building. Similarly, a programmer
prefers to draw a flowchart prior to writing a computer program. As
in the case of the drawing of a blueprint, the flowchart is drawn
according to defined rules and using standard flowchart symbols
prescribed by the American National Standard Institute, Inc.
Different flow chart symbols have different meanings.The following
are the most common flow chart symbols:

Common Flow Chart Symbols


Name Symbol Use

Oval Denotes the


beginning or end
of a program.

Flow line Denotes the


direction of logic
flow in a
program.

Denotes either
Parallelogra an input
m operation (e.g.,
INPUT) or an
output operation
(e.g. PRINT)

Denotes a
Rectangle process to be
carried out (e.g.,
an addition).

Denotes a
Diamond decision (or
branch) to be
made. The
program should
continue along
one of two
routes

9
 Terminator: An oval flow chart shape indicating the start or end
of the process.
 Process: A rectangular flow chart shape indicating a normal
process flow step.
 Decision: A diamond flow chart shape indication a branch in
the process flow.
 Connector: A small, labeled, circular flow chart shape used to
indicate a jump in the process flow.
 Data: A parallelogram that indicates data input or output (I/O)
for a process.
 Document: used to indicate a document or report

PHASE 4: Systems Implementation


In the implementation phase, the system is actually built. This phase
includes: System Construction, System Testing, Installation,
Training plan and System Evaluation.

System Construction
After designing the new system, the whole system is ready to be
translated from program specifications into computer instructions
using a programming language of choice. This process is known as
coding.

System Testing
After the system is built, it is then tested to ensure it performs as
designed. A test plan should be developed and run on a given set of
test data. The output of the test run should match the expected
results. Test to be performed: Unit Test, Integration Test and System
Test.

Installation
After testing the system is tested, it will be deployed to the client and
be used by the end‐users.

Training Plan
Training Plan includes detailed instructions on how to use the new
system and help manage the changes caused by the new system.

System Test

10
Post‐implementation evaluations verify that the new system meets
specified requirements, complies with user objectives, and produces
the anticipated benefits.

PHASE 5: Systems Operation, Support and Security


The analyst team establishes a support plan that usually includes a
formal or informal post‐implementation review, as well as a
systematic way for identifying major and minor changes needed for
the system. System security measures involve different security
levels: Physical Security, Network Security, Application Security, File
Security and User Security.

A Brief Java History


Java programming language was pioneered by a group of engineers of
Sun Microsystems led by James Gosling in June 1991 through a
project known "Oak". The name Java emerged in light of the fact that
there was already a language called Oak.
Gosling's goals were to implement a virtual machine and a language
that had a familiar C‐like notation but with greater uniformity and
simplicity than C/C++. The first public implementation was Java 1.0
in 1995. It made the promise of "Write Once, Run Anywhere", with
free runtimes on popular platforms. It was fairly secure and its
security was configurable, allowing for network and file access to be
limited. The major web browsers soon incorporated it into their
standard configurations in a secure "applet" configuration.

Java Technology

What is Java Technology?


 A programming language
As a programming language, Java can create all kinds of
applications that you could create using any conventional
programming language.
 A development environment
As a development environment, Java technology provides you with
a large suite of tools: a compiler, an interpreter, a documentation
generator, a class file packaging tool and so on.
 An application environment Java technology applications are
typically general‐purpose programs that run on any machine
where the Java Run time Environment (JRE) is installed.
 A deployment environment Java technology has two main
deployment environments: First, the JRE supplied by the Java 2
Software Development Kit (SDK) contains the complete set of

11
classes for all the Java technology packages, which includes
basic language classes, GUI component classes, and so on. The
other main deployment environment is the web browse. Most
commercial browsers supply a Java Technology Interpreter and
Runtime environment.

Some Features of Java


 The Java Virtual Machine
The Java Virtual Machine (JVM) is an imaginary machine that is
implemented by emulating software on a real machine. The JVM provides
the hardware platform specifications to which you compile all Java
technology code. This specification enables the Java software to be platform‐
independent because the compilation is done for a generic machine known
as the JVM.
A bytecode is a special machine language that can be understood by the
Java Virtual Machine (JVM). The bytecode is independent of any
particular computer hardware, so any computer with a Java interpreter
can execute the compiled Java program, no matter what type of computer
the program was compiled on.
 Garbage Collection
Many programming languages allow a programmer to allocate memory
during runtime. However, after using that allocated memory, there should
be a way to deallocate that memory block in order for other programs to use
it again. In C, C++ and other languages the programmer is responsible for
this. This can be difficult at times since there can be instances where in the
programmers forget to de‐allocate memory and therefore result to what we
call memory leaks.
In Java, the programmer is freed from the burden of having to de‐allocate
that memory themselves by having what we call the garbage collection
thread. The garbage collection thread is responsible for freeing any memory
that can be freed. This happens automatically during the lifetime of the Java
program.
 Code Security
Code security is attained in Java through the implementation of its Java
Runtime Environment (JRE). The JRE runs code compiled for a JVM and pe
rforms class loading
(through the class loader), code verification(through thebytecode verifier)
and finally code execution.
The Class Loader is responsible for loading all classes needed for
the Java program. It adds security by separating the namespaces for the
classes of the local file system from those that are imported from network
sources. This limits any Trojan horse applications since local classes are

12
always loaded first. After loading all the classes, the memory layout of
the executable is then determined. This adds protection against
unauthorized access to restricted areas of the code since the memory
layout is determined during runtime.
After loading the class and lay outing of memory, the bytecode verifier th
etests the format of the code fragments and checks the code fragments for
illegal code that can violate access rights to objects.
After all of these have been done, the code is then finally executed.

Processing a Java Program


The following figure describes the process of compiling and executing Java
program.
The following figure describes the process of compiling and executing a Java
program.

Source: https://sites.google.com/site/beginnerofcs/object-oriented-program
Figure 2: Five Phases in Java Program
Phase 1: Creating a Program

13
Phase 1 consists of editing a file with an editor program (normally known
simply as an editor). You type a Java program (typically referred to as source
code) using the editor, make any necessary corrections and save the
program on a secondary storage device, such as your hard drive. A file
name ending with the.java extension indicates that the file contains Java
source code. We assume that the reader knows how to edit a file. Two
editors widely used on Linux systems are viand emacs. On Windows, a
simple editing program like Windows Notepad will suffice. Many freeware
and shareware editors are also available for download from the Internet.
For organizations that develop substantial information systems,
integrated development environments (IDEs)are available from many major
software suppliers, including Sun Microsystems. IDEs provide tools that
support the software development process, including editors for writing
and editing programs and debuggers for locating logic errors.

Phase 2: Compiling a Java Program into Bytecodes


In Phase 2, the programmer uses the command javac (the Java compiler) to
compile a program. For example, to compile a program called
Welcome.java, you would type javac Welcome.java in the command
window of your system (i.e.,the MS‐DOS prompt in Windows 95/98/ ME,
the Command Prompt in Windows NT/2000/XP, the shell prompt in Linux
or the Terminal application in Mac OS X). If the program compiles, the
compiler produces a class file called Welcome class that contains the
compiled version of the program.
The Java compiler translates Java source code into bytecodes that represen
tthe tasks to execute in the execution phase(Phase 5). Bytecodes are
executed by the Java Virtual Machine (JVM)—a part of the JDK and the
foundation of the Java platform. A virtual machine (VM) is a software
application that simulates a computer, but hides the underlying operating
system and hardware from the programs that interact with the VM.

Phase 3: Loading a Program into Memory


In Phase 3, the program must be placed in memory before it can execute—
known as loading. The class loader takes the .class files containing the
program’s bytecodes and transfers them to primary memory. The class
loader also loads any of the .class files provided by Java that your program
uses. The .class files can be loaded from a disk on your system or over a
network(e.g., your local college or company network, or the Internet).

Phase 4: Bytecode Verification


In Phase 4, as the classes are loaded, the bytecode verifier examines their
bytecodes to ensure that they are valid and do not violate Java’s security
restrictions. Java enforces strong security, to make sure that Java programs

14
arriving over the network do not damage your files or your system (as
computer viruses and worms might).

Phase 5: Execution
In Phase 5, the JVM executes the program’s bytecodes, thusperforming the
actions specified by the program. In early Java versions, the JVM was
simply an interpreter for Java bytecodes. This caused most Java programs
to execute slowly because the JVM would interpret and execute
one bytecode at a time. Today’s JVMs typically execute bytecodes using a
combination of interpretation and so‐called just‐in‐time(JIT) compilation.
In this process, The JVM analyzes the bytecodes as they are interpreted,
searching for hot spots— parts of the bytecodes that execute frequently.
For these parts, a just‐in‐time(JIT) compiler—known as the Java.
HotSpot compiler translates the bytecodes into the underlying computer’s
machine language. When theJVMencountersthesecompiled parts again,the
faster machine‐language code executes. Thus Java programs actually go
through two compilation phases—one in which source code is translated
into bytecodes (for portability across JVMs on different computer platforms)
and a second in which, during execution, the bytecodes are translated into
machine language for the actual computer on which the program executes.

Task Tool to Use Output


Write the program Any Text Editor File with .java extension
Compile the program Java Compiler File with .class
extension (Java
bytecode)
Run the program Java Interpreter Program Output

Table 2.1: Summary of Processing of a Java Program

III. Accompanying DepEd Textbook and Educational Sites (With


Possible Materials for experiments/activities)

Gosling, J., Joy, B., Steele, G., Bracha, G., & Buckley, A. (2014). The
Java® Language Specification. Retrieved from
https://docs.oracle.com/javase/specs/jls/se8/jls8.pdf
Hebb, N. (n.d.). What is a Flow Chart? Retrieved from BreezeTree
Software: https://www.breezetree.com/articles/what-is-a-flow-
chart/
History of Java programming language. (n.d.). Retrieved from Free
Java Guide: http://www.freejavaguide.com/history.html

15
Java Example Codes and Tutorials. (n.d.). Retrieved from Rose India:
https://www.roseindia.net/java/
Malik, D. S. (2006). Java Programming: From Problem Analysis to
Program Design (2nd ed.).
Pandey, S. B. (n.d.). Retrieved from
http://www.geocities.ws/shaileshpandeynec/cflowchart.pdf

IV. Activity Proper


A. Multiple Choice. Direction. Select the letter of the correct answer.
Write your answers on a separate sheet of paper.
1. It refers to the flow of data through an information processing
system.
a. Flowchart b. Pseudocode c. Decision d. Graph
2. What is a special machine language that can be
understood by the Java Virtual Machine?
a. Bit b. Byte c. Bytecode d. Gigabyte
3. What is the file extension of a compiled java file?
a..java b. .class c. .docx d. .exe
4. When is the first public implementation was Java 1.0?
a. 1995 b. 1996 c. 1994 d. 1997
5. What do you call an imaginary machine that is
implemented by emulating software on a real machine?
a. JAVA b. JRE c. GUI d. JVM

B. Pseudo Code Writing


On a separate sheet of paper, design a pseudocode with
corresponding flowchart for a pharmacy. The program should be
designed with these features: First, the user will be prompted for
his/her desired product and quantity to be purchased. The program
will then calculate for each product’s total amount. After this, it will
calculate the total bill of all the purchased products. The program
will then display the purchased goods and quantity on the screen, as
well as the total amount of each product and the total bill of all the
purchased products.
C. Scoring Rubric

Criteria Percentage
Creativity and Originality. The 40%
pseudo code is simple and the
process is written with learner’s
own language. Exhibited
uniqueness of style and

16
execution process.
Clarity and Logic. The code
shows clear output. Every step
shows logical connections from 40%
the previous and next stage of
execution.
Application of Principles. The
principles of systems
development are applied. Each
20%
step shows executability of the
code. Flow charting is used and
consistent with the code.

V. Reflection (Provide reflection guide question)


1. What insights have you gained from the activity?
____________________________________________________________________
____________________________________________________________________
__________________________________________________
2. How important flowchart in creating a program??
____________________________________________________________________
____________________________________________________________________
__________________________________________________
3. Describe the process of compiling and executing a Java
program.
____________________________________________________________________
____________________________________________________________________
__________________________________________________

V. Answer Key

17

You might also like