OOP
Concepts and Java
Fundamentals
SHERWIN M. CAACBAY, MIT
Learning Objectives
1. Discuss
principle
the
of
basic
object
oriented programming;
4. Explain the basic
structure of Java source
file;
2. Explain the use of Java
environment; 5. Illustrate the phases of a
Java program; and
3. Explain the different
characteristics of Java; 6. Discuss compilation in
java.
What is OOP?
● Object means a real-world
entity such as a pen, chair,
table, computer, watch, etc.
Object-Oriented Programming
is a methodology or paradigm
to design a program using
classes and objects. It simplifies
software development and
maintenance by providing
some concepts:
What is OOP?
● As the name suggests, Object-Oriented
Programming or OOPs refers to languages
that uses objects in programming. Object-
oriented programming aims to implement
real-world entities like inheritance, hiding,
polymorphism in programming.
What is an OBJECT?
● Any entity that has state and
behavior is known as an
object. For example, a chair,
pen, table, keyboard, bike,
etc. It can be physical or
logical.
What is an OBJECT?
● An Object can be defined as
an instance of a class. An
object contains an address
and takes up some space in
memory. Objects can
communicate without
knowing the details of each
other's data or code.
What is a CLASS?
● Collection of objects is called
class. It is a logical entity.
● A class can also be defined as
a blueprint from which you
can create an individual
object. Class doesn't consume
any space.
OOP Concepts
INHERITANCE POLYMORPHISM
When one object acquires If one task is performed
all the properties and in different ways.
behaviors of a parent object
ABSTRACTION ENCAPSULATION
Hiding internal details and Binding (or wrapping)
showing functionality. code and data together
into a single unit.
Object Oriented Programming in Java
● Java is one of the most ● From desktop to web
popular and widely used applications, scientific
programming language supercomputers to gaming
and platform. A platform is consoles, cell phones to the
an environment that helps Internet, Java is used in
to develop and run every nook and corner.
programs written in any
programming language.
Java is fast, reliable and
secure.
History of Java
OAK 1991 JAMES GOSLING
It was the initial It was the year Development
name of JAVA when Java was leader in Sun’s
created. microsystem
1995 STAR 7
Oak was First project
redesigned and developed using
renamed to Java. Java.
Characteristics of Java
SIMPLE OBJECT-ORIENTED MODEL
Java is easy to write and Like C++ java provides most
more readable and eye of the object-oriented
catching. features.
PLATFORM INDEPENDENT ROBUST
Java language is guaranteed Java encourages error-free
to be write-once, run- programming by being
anywhere language. strictly typed and
performing run-time checks.
Characteristics of Java
SUPPORTS MULTI-THREADING HIGH PERFORMANCE
Java provides integrated Bytecodes are highly
support for multithreaded optimized.
programming. JVM can executed them
much faster.
STRONG SECURITY PORTABLE LANGUAGE
Java program cannot harm Java programs can execute
other system thus making it in any environment for
secure. which there is a Java run-
time system
Java Environment
JDK JRE JVM
allow developers to is the on-disk part of is the Java platform
create Java programs Java that creates the component that
that can be executed JVM. executes programs.
and run by the JVM and
JRE.
The Java Source File Structure
o Each Java source file must
have the same name as a
public class that it declares.
o Each Java source file can
contain only one public class
declaration.
o The file extension must be
.java.
o The filename is case-
sensitive. Therefore, the
preceding source code must
be stored in a file named
NewClass.java.
Phases of a Java Program
One time only Every time
EDITOR COMPILER INTERPRETER
Hello.java Hello.class
Summary of the Phases of a Java Program
TASK TOOL TO USE OUTPUT
Write the program Any text editor File w/ .java extension
File w/ .class extension
Compile the program Java compiler
(Java bytecodes)
Run the program Java interpreter Program Output
Compilation in Java
● In Java, programs are not compiled into
executable files; they are compiled into
bytecode, which the JVM (Java Virtual Machine)
then executes at runtime. Java source code is
compiled into bytecode. The bytecode gets
saved on the disk with the file extension .class.
When the program is to be run, the bytecode is
converted, using the just-in-time (JIT) compiler.
The result is machine code which is then fed to
the memory and is executed.
References
● https://www.javatpoint.com/java-oops-
concepts
● https://ukdiss.com/examples/java-
language.php
● https://www.quora.com/What-are-the-
characteristics-of-java