You are on page 1of 17

Republic of the Philippines

ISABELA STATE UNIVERSITY


San Mateo Campus

BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY

IT88 – IT ELECTIVE 4 (Java Programming)

Module 1: Programming Concepts and Java Programming

Introduction
This chapter focused on programming principle and terminologies on how the
program/code works with the use of Integrated Development Environment (IDE) so
that students will be familiarized on the process of the program execution.

Learning Outcomes

At the end of the discussion, students are expected to:


 Identify and explain the different stages in developing a computer program
 Differentiate algorithm from pseudocode
 Discuss the concept of program and comments in Java
 Identify the use of compilers and interpreters in the program
 Differentiate interpreter from compiler
 Identify and explain the different types of programming errors
 list the generations of programming languages
 identify and explain the different types of programming languages
 identify and explain the different types of applications of Java
 identify the characteristics and benefits of Java
 construct and solve Java Programming problems

Learning Content

Every computer program has to be well – planned and executed correctly.


Instructions must be ordered in a logical sequence that can easily be understood by the
computer. The problem must be analyzed to such a level of detail that all logical
conditions that may be encountered during the process are taken into consideration.
As we all know computers are just a tool, it does not have its own mind. It is very
dependent to the programmer who gives instruction to it. We must make sure we
analyze the problem very well before we start writing some codes using programming
language such as Java.

There are six stages in developing a computer program.

1. Defining the problem


2. Designing a solution to the problem
3. Writing the program
4. Compiling, debugging and testing the program
5. Documenting the program
6. Maintaining the program

Defining the Problem

The first step in defining a problem begins with recognizing the need for
information. As we all know all information is very important primarily because such
information can help us in making a good decision. This information may be
requested for a solution to a particular problem. The problem is thoroughly analyzed
in order to determine what is required for its solution.
To better understand and analyze the problem we must conduct a study of the
nature of the problem and we must able to identify the necessary outputs required in
the program. In conducting a study or investigation of the problem we must talk to the
end-use of the proposed program we are trying to develop since he understands the
problem prior to writing the necessary code for the program itself.
The programmer must determine what data are needed, what form they are to be
in, what information should the program generate, and how the data are to be
manipulated to produce the result.

Designing a Solution

When the problem is defined properly, we can start designing the solution to the
problem. In designing he solution, we must be able to breakdown the problem into
several steps so that is easier for us to solve the problem in smaller pieces. This
method is called divide and conquer principle. This sequence of steps for the
solution to the problem is called an Algorithm.

Algorithm - It refers to well-defined procedures or instructions to solve a problem.

Flowcharting - One way a programmer can illustrate the sequence of steps in an


algorithm is with a flowchart. A flowchart is a graphical representation of the
sequence of operations where a computer is to perform. Flowcharting uses easily
recognizable symbols to represent the type of processing performed in a program.

Pseudocode – a pseudocode is a version of the instructions describing each step that


the computer must follow. It is written in an abbreviated from of spoken language and
there lies somewhere commands written in ordinary English and those in a computer
language.

Writing the Program

After the programmer has defined the problem and designed a solution, the next
step is to write the program in a specific programming language. Although the
definition and solution of the problem are independent of the programming language,
the proposed solution to the problem, may limit the choices of languages that can be
used.

Program

1. A program is a list of instructions written in a programming language that a


computer can execute so that the machine acts in a predetermined way.
2. Program is synonymous with software. A program is also a sequence of
instructions that can be executed by a computer. The term may also refer to
the original source code or to an executable (Machine Language) version. The
word program also implies a degree 1. of completeness, that is, a source code
program compressing all statements and files necessary for complete
interpretation and compilation, and an executable program that can be loaded
into a given environment and executed independently from other programs.

Despite the fact that programming languages differ in commands they use, high-
level programming languages must have certain types of programming statements in
common. These are comments, declarations, input/output statements, computations,
transfer of control, and comparison.

Comments are statements that have no effect on the program. They are simply
used to make the program easier to understand. They are inserted at the key points in
the program and serve as an internal documentation of the program.

The programmer uses declarations to define items used in the program. Examples
include definitions of files, records, initial values, reusable functions and the like.
Input/output statements transfer data to and from the primary storage for use by
the program, as well as to and from other I/0 devices like the monitor and the
keyboard. Commands such as READ and PRINT are examples of these types of
statements.
Computational instructions perform arithmetic operations such as addition,
subtraction, multiplication, division and exponentiation. Different programming
languages vary in the way they invoke the computer's arithmetic capabilities.
Another type of instruction allows the sequence of execution to be altered by
transferring control. A conditional transfer of control alters the sequence only when a
certain condition met. An unconditional transfer of control always changes the
sequence of execution.
Comparisons allow two items to be compared. Based on the result of the
comparison, input/output, computation, or transfer of control could occur.
As the program is being coded, the programmer should be aware that although
generating the correct output is the primary goal of the program, it is not the only
requirement of a good program. The programmer should try to incorporate the
following qualities into any program.

1. Programs should be easy to read and understand. Data names should be


descriptive. Statements should b e placed in a format that is easy to read
and follow. Placing enough c o m m e n t s can help in making t h e program
easier to understand.
2. Programs should be efficient. Programs should execute in as little time as
possible.
3. Programs should be reliable. Programs should c o n s i s t e n t l y produce t h e
correct output. All formulas and computations, as well as all logic test
and transfer control, must be accurate.
4. Programs must be robust. Programs should w o r k un de r a l l
conditions. Reliability alone is no guarantee for a successful program .
Internal logic may be correct but incorrect data item could produce an
incorrect output. For example, how would a program react if a person's
age is between 16, 29 or -21? Or instead of accepting numerical values
such as 1, 10, 45, the person gives letter A?
5. Programs should be maintainable. They should be easy to. update
and modify. Programs should be written in independent modules so
that a change in one module does not mean change of other modules.

Compiling, Debugging and Testing the Program


The instructions written in a programming language such as Java must b e
translated into machine language before they can be executed. A compiler is a
special program for each programming language that is loaded into the
computer when the language is used. It is translated each line of code into
machine instruction that can easily be understood by the computer.

Compiler

1. A computer program (or set of programs) that transforms source code


written in a programming language (the source language) into another
computer language (the target language, often having a binary f o r m
know n as object code).
2. Refers to any program that transforms one set of symbols into another
by following a set of syntactic and semantic rules. In the most common
sense, a compiler is a program that translates all the source codes of a
program written in a high-level language into object codes prior to the
execution of the program.

Debugging

1. In computers, debugging is the process of locating a n d f i x i n g or


bypassing bugs ( errors) i n computer program code or the engineering
of a hardware device. To debug a program or to fix the hardware is to
start with a problem, isolate the source of the problem, and then fix it.
2. It is the process of correcting programming errors.

Testing
1. A method of assessing the functionality of a software program.
2. The process of checking if a program actually performs its functions as
planned.

Documentation of the Program

Documentation consists of written description and explanation of


programs and other materials associated with an organization’s data
processing system. Documentation of a system and program designs are
one of the most important requirements for success in data processing
application. Proper program documentation serves as a guide for
programmers and system analysts who must modify or update the existing
programs and system procedures.
The process of documentation is an ongoing process in any system being
developed and implemented. It begins with the initial request for information.
The individual making the request should be identified. So, should those
responsible for designing the system and required programs.
During the problem definition state, the problem should be described clearly
in a short and narrative statement. The objectives of the program should be
included with the problem statement. Several other descriptions are needed.

1. A complete description of the contents and f o r m a t s of all data


i n p u t s , outputs and files to be used.
2. A statement of hardware requirements for running the program, as well
as estimated processing time and storage requirements.
3. A statement of software requirements, such as utility programs and
library programs.

In the planning phase, t h e most important documentation produced is


the flowchart and ps eudocode . Descriptive comments may be included in
each processing step. The test data used to test the program should also be
included.

Maintenance
During the implementation of the s y s t e m , there a r e s ome c h a n g e s in
the program that w i l l occur d e p e n d i n g on the· nature of the system that i s
being developed. Maintenance is one of the most important aspects i n
developing a computer program in a sense that is there are errors or bugs that
are spotted by the user it should be fixed as soon as possible in order to avoid
big problems along the way of using the system. Let say, for example, the
user has discovered that' every time a new record is being added in the
database the record is not being saved correctly h a v i n g this problem i s very
c r i t i c a l in any business organization. This problem should be corrected
right away from the programmer, so that it will not hamper the day-to-day
operation of the company.

Bugs refers to errors in a computer program.

Types of Programming Errors

1. Syntax errors - Errors due to the fact that the syntax of the language is
not respected.
2. Semantic errors - Errors due to an improper use of program statements
3. Logical errors - Errors that occur when the specification is not respected.
4. Compile time errors - Syntax errors and static semantic errors
indicated by the compiler.
5. Runtime errors - Dynamic semantic errors and logical errors that
cannot be detected by the compiler (debugging).

Programming Language

1. A programming language is an artificial language designed to


communicate instructions to a machine, particularly a computer.
2. Programming languages can be used to create programs that control
the behavior of a machine and/or to express algorithms precisely.
3. Software used to create another software.

Generations of Programming Languages

1. First Generation: Machine Language


2. Second Generation: Assembly Language
3. Third Generation: High-level Language
4. Fourth Generation: Object – Oriented Programming
5. Fifth Generation: Logic Programming

First Generation (1GL)

1. Machine Language
2. Uses binary codes that consist of string of only zeroes and ones.
3. These are languages that a computer can understand and execute
directly.
4. Machine dependent
5. Low – level Language

Second Generation (2GL)

1. Assembly Language
2. Instead of zeroes and ones, it uses mnemonics or very short words for
commands.
3. Program written in assembly language must be converted by an
ASSEMBLER.
4. Low level language TASM, MASM.

Third Generation (3GL)

1. High – Level Language


2. Can write programs that are more or less independent of a particular
type of computer.
3. It is considered high – level because they are close to human
languages and they are easier to read, write, and maintain.
4. Uses a COMPILER to translate the source code into machine readable
code.
5. FORTRAN, BASIC, COBOL, Pascal, C, C++, Algol, Ada.

Fourth Generation (4GL)

1. Object Oriented Programming Language


2. Organize coding around objects
3. Event drive – event triggers the outcome of the program
4. Java, C++, C#, Visual Basic, VB.Net

Fifth Generation (5GL)

1. Logic Programming
2. Artificial Language
3. Operates on the concept of solving problems based on constraints or
rules that have been declared in the program.
4. The focus is on making the computer program solve the problem for
you.
5. Uses knowledge bases and expert system
6. PROLOG, Mercury, LISP
7. PROGRAMMING PARADIGMS
8. Imperative
9. Functional
10. Logic
11. Object-Oriented
12. Concurrent and Distributed

Imperative Programming

1. Refers to a mood of expressing an essential order or command


2. It describes computation in terms of a program state and actions that
change the state.
3. The program consists of explicit commands or instructions to be
executed, performing operations on data modifying values of program
variables and the external environment.

Functional Programming
1. Computations are specified through mathematical functions that
evaluate input expressions and convert them into output values.
2. Functional programming languages are “what” – oriented.
3. They describe the problem to be solved rather than specify the actual
steps required for the solution.
4. LISP, Haskell, Scheme, Standard ML.

Logic Programming

1. Programs are written i n logical statements that, describe t h e


properties that solutions must have.
2. Based on the concept of logical deduction in symbolic logic, or the
manipulation of symbols
3. PROLOG, Constraint Logic Programming (CLP)

Object Oriented Programming

1. Data structures are viewed as objects, and programmers create


relationships between these objects.
2. A group of objects that have the same properties and behaviors is called a
CLASS
3. Java, C++, Visual Basic, VB.Net, C#

Concurrent and Distributed Programming

1. Program technique that allows for the execution of two or more


operations at the same time
2. Concurrent means occurring at the same time
3. Parallel suggests that the processes run side-by-side yet independently
with each other.

TYPES OF PROGRAMMING LANGUAGES

Machine Language

It is the only language that t h e computer understands. It consists o n l y of


binary numbers 0 and 1. The use of binary numbers as basis of machine language
was proposed Dr. John Von Neumann. Each different type of CPU (Central
Processing Unit) h a s its o w n unique machine language. Programs
written in machine l a n g u a g e is very fast in terms of program execution and
us es only minimal amount of computer resources such as memory, hard drive
and C P U but it is not easy to write, debug a n d test programs written in machine
language on the part of the programmer. Machine language is widely used in
1930's up to early 1950's primarily because of the small storage capacity and CPU
speed of computer during that time.

Advantage of Machine Language:


The only a d v a n t a g e of machine l a n g u a g e is it. runs v e r y f a s t
because n o translation program is required for the CPU.

Disadvantage of Machine Language:

1. It is very difficult to program in machine language. The programmer has


to know details of the computer hardware to write the program.
2. The programmer has to remember a lot of codes to write a program
which usually results in program errors.
3. It is difficult to debug the program.
4. It is very difficult to maintain and modify the program.
5. It is designed to work in a particular computer hardware architecture.

Example of Machine Language


ba Oc 01
b409
cd21
b8 00 4c
cd21 ·
48 65 6c 6c 6f 2c
20 57 6f 72 6c 64
21Od Oa 24

Low Level Language

Low-level language is also known as assembly language. This is a type


of low-level programming language in which each program statement corresponds
to an instruction that the microprocessor can carry out. Assembly languages are
thus specific to a given microprocessor or CPU (Central Processing Unit) of the
computer. After writing an assembly language p r o g r a m , the programmer must
use the assembler specific to the processor to translate the assembly language into a
corresponding machine code that computers understand. An assembly language
provides precise control o f the computer, but a s s e m b l y l a n g u a g e
programs written for one type of computer m u s t be rewritten t o operate on other
types. An assembly language might be used instead of a high-level language for
any of these three major reasons: speed, control, and preference. Programs written
in an assembly language usually run faster than those generated by a compiler.
The use of assembly language allows a programmer to interact directly with the
hardware, including the processor, memory display, and input/out ports.

Advantages of Low – Level Languages

1. It consists of binary digits and some symbols.


2. Very fast program execution
3. It depends on the machine.
4. Machine language directly executes on a computer.
5. No need of language translator for machine language
6. Program written in low level language is called object code.

Disadvantages of Low – Level Languages

1. It is not easy to understand.


2. It is difficult to modify.
3. Program written in low level language can run only on specific
microprocessor or CPU.

High – Level Programming Language

High level programming languages enable the programmer to write programs


that are more or less independent of a particular type of computer. Such languages
are considered high level because they are closer to human language that the
machine languages t h e computer t r u l y understands. The main advantage of
a high-level language over, low-level language is that they are easier to
understand, modify and debug. They allow the programmers to focus on solving
the problem rather than knowing how to program a computer.
Ultimately, programs written in a high- l e v e l language must be translated into
machine language the language that computers understand. A good example of
high-level language are COBOL, RPG, FORTRAN, Modula-2, LOGO, C, C+ +,
Java, C#. JavaScript, BASIC and Pascal. Since their development in the 1950's,
many other languages have been developed today.
The question of what programming language to use depends on the type of
problem you want to solve. Every language has its advantages and disadvantages.
For example, Pascal is very good to use a tool in teaching fundamentals in
computer programming in schools, but it is not good in creating web
applications. Java is a very good Language to use in writing secure, robust and
web ready applications. It is also a great language to learn object-oriented
programming that is very helpful in creating large software applications.

Advantages and Disadvantages of High-Level languages:

1. It is close to a human being.


2. It is easy. to understand.
3. It consists of English language like structure.
4. It does not depend upon the machine.
5. It is easy to modify.
6. The programs written in high level languages are
called source code.
Here are some disadvantages of High – Level Languages
1. It needs language translator to translate program into
machine language.
2. It is very slow in terms of program execution compared to machine or
assembly language.
3. It needs big amount of system resources such as memory, disk
space and CPU speed to run the program properly.
4. It does not execute directly on the computer.

Interpreters and Compilers

Regardless of what type of language you are using, eventually you will
convert your program into a machine language so that the computer can
understand and execute your program. When we write our programs in a
high-level language the computer does not understand the language
because it is only operated with bit or one's and zero’s. There is a need
for translation process that will. convert the programs written in high-
level language into machine language. '

There are two ways of doing this, either compile t h e program or


interpret the program. The process of compiling and interpreting a
program can be accomplished b y using other programs called compilers
and interpreters, these programs translate t h e program written i n high-
level language i n t o ma ch in e language.

Compiler

A compiler is a program t h a t translates a program w r i t t e n i n a high-


l e v e l language (source code) and translates into machine language (object
code). The compiler derives its name from the way it works. The first practical
compiler was written by Commodore G r a c e Murray Hopper of United States
Navy in 1952; she named it A compiler. It analyzes the entire piece of source
code and then re organizes the instructions and then translates into machine
code.
Every high-level programming language (except strictly interpretive languages)
comes with a compiler. In the effect, the compiler is the language because it defines
which instructions are acceptable and which are not.
Source Code is any series of statements written in some high level computer
programming language.

The term is typically used in the context of a particular piece of computer


software. A computer program’s source code is the collection of files that can be
converted from human – readable form to an equivalent computer – executed from in
machine language. The source code is either converted into an executable file by a
compiler for a particular computer architecture, or executed on the fly from the human
readable form with the aid of an interpreter.
Object Code, also known a s object file, is an intermediate representation
of code generated by a compiler after it processes a source code file. Object files
contain compact, pre-parsed c o d e , often called binaries that can be linked with
other object files to generate a final executable or code library. An object file is
mostly machine code that can be directly executed by a computer's CPU. An object
file contains not only the object code, but also relocation information t h a t the
linker uses to assemble multiple object files into an executable or library, program
symbols (names of variables and functions), and debugging information.
Programming languages that use compilers are Java, C, C++, BASIC, Fortran,
COBOL, Go, Felix, D, Oberon, Pascal, Python, Eiffel, Smalltalk, Haskell, Batch and
CLI.

Source Code Object Code Machine

This is How Compilers Work

Interpreter

The most common way to translate a high-level language to machine


language is to compile the program; the other method is to pass the program
through an interpreter. The interpreter translates and e x e c u t e s the
p r o g r a m line b y line. An interpreter translates into a n intermediate form,
which i t then executes . In contrast, a compiler t r a n s l a t e s high-level
instructions or commands directly into machine language. The first
interpreter was written by Steve Russell on an IBM 704 computers in 1958.
The first high-level language that uses an interpreter to translate its code into
machine code is LISP or List Processing language written and developed by
John McCarthy in l958.
The advantage of an interpreter, however, is that it does not need to go
through the compilation stage during which machine instructions are
generated. This compilation process can be time consuming if the program is
long. The interpreter, on the other hand, can immediately execute high level
programs.
Programming languages that use interpreters are LISP, BASIC, Java, Pascal,
Ruby and Python.

Intermediate
Source Code Interpreter
code

This is how Interpreter Works

Comparison between Compiler and Interpreter


COMPILER INTERPRETER
Scans the entire program and Translates program one statement at a
translates it as a whole into machine time.
code.
It takes large amount o f time It takes less amount of time t o
to analyze the source code but the analyze the source code but the
overall execution time is overall execution time-is slower.
comparatively faster.
Generates intermediates object code No intermediate object code is
which further requires linking, generated; hence it is memory
hence requires more memory efficient.
It generates the error message only Continues translating the program
after scanning the whole program. until the first error is met, in which
Hence, debugging is comparatively case, it stops. Hence debugging is
hard. easy.
Programming language like C, C++ Programming languages like python
uses compilers and Ruby use interpreters

INTRODUCTION TO JAVA LANGUAGE

Java programming language is one of the most p o p u l a r and w i d e l y


used programming languages, both i n e d u c a t i o n and i n t h e i n d u s t r y , it
was f i r s t written and developed by Dr. James Gosling and his colleagues in
early 1990's at Sun Microsystem, which is now part of Oracle Corporation
after its acquisition was completed on January 27, 2010. Java was released in
1995 as part o f Sun Microsystem's Java platform. The language itself is
based primarily in terms of syntax and structure in C and C++.
Java is an open s o u r c e language that is freely available over the- Internet
to download and u s e . All Java applications are us ua ll y compiled to b y t e
codes of class files that can run o n any Java Virtual Machine. One of the
interesting features of the Java language is that it is an object-oriented
language that makes software development much e a s i e r t o design and
i m p l e m e n t . It uses c l a s s e s , methods and objects to create applications.
Applications written in Java can run on many different operating systems with
little or no modification of the code. This makes Java a platform independent
language that makes the life of the developer or programmer much easier in
porting their applications on different operating systems with e a s e . Java does
t h i s by making the Java compiler turn the code into Java byte code instead of
machine code. It means that when (re - execute _the program that we have
written, the Java Virtual Machine interprets the byte code and it translates it
into machine code.
Nowadays Java programming language is used primarily in school in
teaching computer programming concepts among students. It is the syntax
and commands that is easy to understand and it teaches the students to write
better code because it uses object-oriented concepts in writing a program.

Brief History of Java

James Gosling, M i k e Sheridan, and Patrick Naughton initiated the


J a v a language project in J u n e 1991. Java w a s o r i g i n a l l y designed for
i n t e r a c t i v e television, but it was too advanced for the digital cable
television industry at the time. The language was initially c al le d Oak after an
oak tree that stood o u t s i d e Gosling's office. Later the project went by the name
Green and was finally renamed Java, from Java coffee. Gosling designed Java
with a C/C++style syntax that system and application programmers would
find familiar.
Sun Microsystems released the first public implementation as Java 1.0 in
1995. It promised "Write Once, Run Anywhere" (WORA), providing no-cost
run-times on popular platforms. Fairly secure and featuring configurable
security, it allowed network- and file-access restrictions. Major web browsers
soon incorporated the ability to run Java applets within web pages, and Java
quickly became popular. The Java 1.0 compiler was rewritten in Java by Arthur
van Hoff to comply strictly with the Java 1.0 language specification. With the
advent of Java 2 (released i n i t i a l l y as J2SE 1.2 in December 1998- 1999),
new versions had multiple configurations built for different types of
platforms. J2EE included technologies and APis for enterprise applications
typically run in server environments, while J2ME featured APis optimized for
mobile applications. The desktop version was renamed J2SE. In 2006, for
marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and
Java SE, respectively.
In 1997, Sun Microsystems approached the ISO/IEC JTC 1 standards
body and later the Ecma International to formalize Java, but it soon withdrew
from the process. Java remains a de facto standard, controlled through the Java
Community Process. At one time, Sun made most of its Java implementations
available without • charge, despite their proprietary software status. Sun
generated revenue from Java through the selling of licenses for specialized
products such as the Java Enterprise System.
On 13 November, 2006, Sun released m u c h of Java as free and open-
source software, (FOSS), under t h e terms of the GNU General Public License
(GPL). On May 8, 2007, Sun finished t h e process, making all of Java’s core
code available under free software/open-source distribution terms, aside from a
small portion of code to which Sun did not hold the copyright.
Sun's vice-president Rich Green s a i d that Sun's ideal role with regard
to Java was as an "evangelist." Following O r a c l e Corporation's acquisition of
Sun Microsystems in 2009-2010, Oracle has described itself as the "steward
of Java technology with a relentless commitment to fostering a community of
participation and transparency." This did not prevent Oracle from filing a
lawsuit against Google shortly after that for using Java inside the Android
SDK. Java software runs on everything from laptops to data centers, game
consoles to scientific supercomputers. On 2 April, 2010, James Gosling resigned
from Oracle.

Types of Java Applications


There are many types of Java programs which run differently:

1. Java Applet is usually stored on a website and is downloaded and runs


on a client computer from within a web browser.
2. Application can only run on the computer. If online, it has to be
downloaded before being run.
3. JAR (Java Archive) File is used to package Java files together into a single
file. (Almost exactly like a .zip file.)
4. Servlet runs on a web server and helps to display web pages.
5. Swing application is used to build an application that has
a GUI (windows, buttons, menus, etc.)
6. EJB (Enterprise Java Beans) runs on a web server and is used
to develop large, complex websites

Characteristics of Java
1. Java is simple.
2. Java is object-oriented.
3. Java is distributed.
4. Java is interpreted
5. Java is robust.
6. Java is secure.
7. Java is architecture-neutral.
8. Java is portable.
9. Java's performance.
10. Java is multithreaded.
11. Java is dynamic.

Benefits of Java

1. Java is commonly used to teach students how to program as a first


language, yet is still also used by professionals.
2. Java requires that each variable be initialized. Some older languages
such as C, allow variables to go uninitialized, which can cause
random failures with mysterious bugs.
3. Java requires that each method that declares a return type, always
returns a value. This also prevents bugs.
4. Java comes with a large set of classes and methods, the Java API that
can be used without having to develop as much code "from scratch."
5. Unlike C, Java primitive types, such as int, are always the same size
in the number of bits which helps achieve ross-platform
compatibility.
6. Java used to be thought of as being slower than C, but that's less
important in recent years with computers being faster.
7. Java has exception -handling that r e q u i r e s a programmer to
handle error conditions such as an input/output errors.
8. Code c o m p i l e d on one Java platform can be run· on other
platforms that support Java without modification of either the source-
code nor the byte-code. For example, this means that a person can make
a Java program for a Windows computer and have it run on Linux
computer or a Mac computer.

Example of a Java Program

class Hello_World {
public static void main (String [] args){
System.out.println(“Welcome to Java Programming”);
}
}

Sample Program Output

Welcome to Java Programming

Reference

Pomperada, J. R. (2018). Introduction to Java Programming Revised Edition (Revised Edition).


Mindshapers Co,,INC.

You might also like