CC103
Computer
Programming 2
(Java)
Dr. Marygin E. Sarmiento
Professor
Learning Outcomes:
To enumerate the features of OOP
To describe the characteristics of Java
language
To understand how the Java program
works
To form variable name based on the
rules
To list the data types and its sizes
To understand how the Java operators
work
Introduction
Object-Oriented Programming
When you program without using OOP (Object-
Oriented Programming), you are programming
procedurally. A procedural program is a step-
by-step program that guides the application
through sequence of instructions.
A procedural/structured program executes
each statement in the literal order of its
commands, even if those commands cause the
program to branch into all directions. C, Pascal,
QBasic and COBOL are all examples of
procedural programming languages
Features of OOP
Encapsulation Abstraction
Capturing data and keeping The ability to represent
it safely and securely from data at a very conceptual
outside interface. level without any details.
Inheritance It hides information to
This is the process by which other class.
a class can be derived from
a base class with all features Message Passing
of base class and some of its Objects communicates
own.it increases code through invoking
reusability. methods and sending
Polymorphism data to them. This
Ability to exist in various feature of sending and
forms. receiving information
among objects through
function parameters.
Brief History of Java
Java, Gosling's new language
having been
developed in 1991, is a needed to be accessible
relatively new by a variety of computer
programming language. processors. In 1994, he
At that time, James realized that such a
Gosling from Sun language would be ideal
Microsystems and his for use with web browsers
team began designing and Java's
the first version of Java
aimed at programming connection to the internet
home appliances which began. In 1995, Netscape
are controlled by a wide Incorporated released its
variety of computer latest version of the
processors. Java is an Netscape browser which
acronym for James, was capable of running
Andy, Van and Arthur Java programs.
Why is it called Java?
It is customary for the While Java is viewed
creator of a programming
language to name the
as a programming
language anything he/she language to design
chooses. applications for the
The original name of this Internet,
language was Oak, until it it is in reality a
was discovered that a general all- purpose
programming language
already existed that was
language which can
named Oak. be used
As the story goes, after independent of the
many hours of trying to Internet.
come up with a new name,
the development team
went out for coffee and the
name Java was born.
What is Java?
Java is two things: a programming language
and a platform.
The Java programming language was
developed by SUN (Stanford University
Network) Microsystems as an object-oriented
language that is used both for general-
purpose business programs and interactive
World Wide Web-based internet programs.
Some of the advantages that made Java
programming language so popular in recent
years are its security features, and the fact
that it is architecturally neutral, which means
that you can use Java to write program that
will run on any platform.
Java is a high-level
programming language that is
all of the following:
Java is also unusual in that each Java
program is both compiled and
interpreted. With a compiler, you
translate a Java program into an
intermediate language called Java
bytecodes or simply bytecode--the
platform-independent codes
interpreted by the Java interpreter.
With an interpreter, each Java
bytecode instruction is parsed and
run on the computer. Compilation
happens just once; interpretation
occurs each time the program is
executed. This figure illustrates how
You can think of Java Java bytecodes help
bytecodes as the make "write once, run
machine code anywhere" possible.
instructions for the You can compile your
Java Virtual Machine Java program into
(Java VM). Every Java bytecodes on any
interpreter, whether platform that has a
it's a Java Java compiler. The
development tool or a bytecodes can then
Web browser that can be run on any
run Java applets, is an implementation of
implementation of the Java VM. For
the Java VM. The Java example, the same
VM can also be Java program can run
implemented in on Windows NT,
hardware. Solaris, and
You can think of Java bytecodes as the
machine code instructions for the Java Virtual
Machine (Java VM). Every Java interpreter,
whether it's a Java development tool or a
Web browser that can run Java applets, is an
implementation of the Java VM. The Java VM
can also be implemented in hardware.
A platform is the hardware or software
environment in which a program runs. The
Java platform differs from most other
platforms in that it's a software-only platform
that runs on top of other, hardware-based
platforms. Most other platforms are
described as a combination of hardware and
The Java platform
operating system. has two components:
The Java Virtual Machine (Java VM)
The Java Application Programming
Interface (Java API)
The Java VM the base for the Java platform
and is ported onto various hardware-based
platforms to name a few common in the
market are Microsoft Internet Explorer and
Netscape Navigator.
The Java API is a The following
large collection of figure depicts a
ready-made Java program,
software such as an
components that application or
provide many applet, that's
useful capabilities, running on the
such as graphical Java platform. As
user interface the figure shows,
(GUI) widgets. The the Java API and
Java API is Virtual Machine
grouped into insulates the Java
libraries program from
(packages) of hardware
As a platform-independent environment,
Java can be a bit slower than native code.
However, smart compilers, well-tuned
interpreters, and just-in-time bytecode
compilers can bring Java's performance close
to that of native code without threatening
portability
What Can Java Do?
Probably the most well-known Java
programs are Java applets. An applet is a
Java program that adheres to certain
conventions that allow it to run within a
Java-enabled browser. This you will be
learning as we go through each lessons.
The most common types of programs in
java are probably applets and applications,
where a Java application is a standalone
program that runs directly on the Java
platform.
Activity#1-Lecture
Answer briefly….
1. What is programming language
in your own perspective ?
2. Differentiate Java from other
programming language
3. Explain the Features of Java..
4. How Java works in a machine?
5. Explain the characteristics of
Java in your own words…
Activity # 1- Install Java
1. Install Java and Netbeans
2. Create a video how to
install Java and Netbeans
using the installer that I
uploaded in our google
drive.