0% found this document useful (0 votes)
33 views13 pages

Module 1

This document provides an overview of Java programming language, including its history and evolution. It discusses how Java was initially developed in the 1990s for programming home appliances. While Java did not catch on for that purpose, it became widely used for web and application development due to its platform independence. The document outlines key events in Java's development and increasing popularity. It also summarizes Java's uses today in areas like web applications, applets, enterprise applications, and mobile devices.

Uploaded by

Ronald Rivera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views13 pages

Module 1

This document provides an overview of Java programming language, including its history and evolution. It discusses how Java was initially developed in the 1990s for programming home appliances. While Java did not catch on for that purpose, it became widely used for web and application development due to its platform independence. The document outlines key events in Java's development and increasing popularity. It also summarizes Java's uses today in areas like web applications, applets, enterprise applications, and mobile devices.

Uploaded by

Ronald Rivera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Object-Oriented Programming

Chapter 1

Fundamental Concepts of JAVA

Introduction

Java is an object-oriented programming language with its runtime environment. It is a


combination of features of C and C++ with some essential additional concepts. Java is well suited
for both standalone and web application development and is designed to provide solutions to
most of the problems faced by users of the internet era.
Chapter 1 contains readings and discussions as well as laboratory hands-on for the
installations on Java programming language. Set of questions and laboratory activities will be
given in order that students can work on individually or by group.

Learning Outcomes:

At the end of the chapter the students should be able:


 Gain knowledge on the overview and characteristics of Java Programming language;
 Familiarize with the Java Environment and structures; and
 Experience writing the first program in Java programming language.

Start your lesson here.

Background History

This chapter will give you a brief history of how Java software came into life, starting
from the existence of computers. It will also provide you a brief overview of the evolution of the
various computer programming languages.

The Birth of Computers

It was not long ago, well maybe around two decades, that there were still typewriters to
create the documents we need at home, in school or for work. Remember your mother’s recipes
on index cards, your thesis in college, your resume for a job application and many more. Then
here comes the birth of computer systems that made everything a whole lot easier! It was a total
revolution when these miracle machines were introduced. Now, with just a click of the mouse or
a keystroke you have photos printed out to decorate your home, a YouTube video of your high
school ball, or a visually compelling marketing presentation for work.
Object-Oriented Programming

Evolution of Computer Programming Languages

•1954-1957
John Backus with an IBM team developed FORTRAN (considered the first
modern computer programming language but definitely not user-friendly).

•1959
Grace Hopper at Remington Rand developed COBOL (Letter B stands for
Business, which is COBOL’s primary feature that included processing records of
customers, employees and more)

•1972
Dennis Ritchie at AT&T Bell Labs developed the C programming language.

•1986
Bjarne Stroustrup at AT&T Bell Labs developed C++ that supported object-
oriented programming (OOP).

•1995
It was exactly on May 23rd that Sun Microsystems released the first official
version of Java programming language that is considered as an improvement of C++.
This general-purpose software enables you to build and explore databases, write
windowed applications and control handheld devices, among others. Just after five years,
Java already had 2.5 million developers worldwide.

• 2000
The College Board announced in November that Computer Science Advanced
Placement exams will be based on Java by 2003.

• 2002
Microsoft introduced C#, a new language named that inherited most of its
programming features from Java. Sys-Con Media reported in June of the same year that
there was an increasing demand for Java programmers (it has exceeded by 50% as
compared to the demand for C++ programmers).

• 2007
Google started developing apps on Android mobile devices using the Java
language. 2010 Oracle Corporation incorporated Java technology into the Oracle family
by purchasing Sun Microsystems in January

• 2010
eWeek ranked Java in June as first among its “Top 10 Programming Languages
to Keep You Employed” (www.eweek.com/c/a/ Application-Development/Top-10-
Programming-Languagesto-Keep-You-Employed-719257).

• 2013
More than 1.1 billion desktop computers and 250 million mobile phones have
been using Java platform since August 2013
(www.mobiledevicemanager.com/mobiledevicestatistics/250-million-android-devices-in-
use and http://java.com/en/about). Moreover, Blu-ray devices emerged with more
interactive capabilities through the new technology. Java was already considered the most
popular language by various programming groups and communities, such as TIOBE
Object-Oriented Programming

Programming Community Index (www.tiobe.com/index.php/ content/paperinfo/tpci) and


PYPL that stands for the PopularitY of Programming Language Index

Emergence of Java Technology

In 1991, James Gosling led a team at Sun Microsystems that developed the first version
of Java (which was not yet called Java). This first version of the language was designed for
programming home appliances, such as washing machines and television sets. Although that may
not be a very glamorous application area, it is no easy task to design such a language. Home
appliances are controlled by a wide variety of computer processors (chips). The language that
Gosling was designing needed to work on all these different processors. Moreover, a home
appliance is typically an inexpensive item, so the manufacturer would be unwilling to invest large
amounts of money into developing complicated compilers. (A compiler translates a program into
a language the processor can understand.) To simplify the tasks of writing compilers (translation
programs) for each class of appliances, the team used a two-step translation process. The
programs are first translated into an intermediate language that is the same for all appliances (or
all computers), and then a small, easy-to-write—and hence, inexpensive—program translates this
intermediate language into the machine language for a particular appliance or computer. This
intermediate language is called Java bytecode, or simply, byte-code. Since there is only one
intermediate language, the hardest step of the two-step translation from program to intermediate
language to machine language is the same for all appliances (or all computers); hence, most of the
cost of translating to multiple machine languages was saved. The language for programming
appliances never caught on with appliance manufacturers, but the Java language into which it
evolved has become a widely used programming language. Today, Java is owned by Oracle
Corporation, which purchased Sun Microsystems in 2010. Why call it byte-code? The word code
is commonly used to mean a program or part of a program. A byte is a small unit of storage (eight
bits to be precise). Computer readable information is typically organized into bytes. So the term
byte-code suggests a program that is readable by a computer as opposed to a person. In 1994,
Patrick Naughton and Jonathan Payne at Sun Microsystems developed a Web browser that could
run (Java) programs over the Internet, which has evolved into the browser known as HotJava.
This was the start of Java’s connection to the Internet. In the fall of 1995, Netscape Incorporated
made its Web browser capable of running Java programs. Other companies followed suit and
have developed software that accommodates Java programs.

What is JAVA?

 Java is an object-oriented programming language developed by Sun Microsystems, and it


was released in 1995.

 James Gosling initially developed Java in Sun Microsystems (which was later merged
with Oracle Corporation).

 Java is a set of features of C and C++. It has obtained its format from C, and OOP
features from C++.

 Java programs are platform independent which means they can be run on any operating
system with any processor as long as the Java interpreter is available on that system.

 Java code that runs on one platform does not need to be recompiled to run on another
platform; it's called write once, run anywhere (WORA).
Object-Oriented Programming

 Java Virtual Machine (JVM) executes Java code, but it has been written in platform-
specific languages such as C/C++/ASM, etc. JVM is not written in Java and hence cannot
be platform independent, and Java interpreter is a part of JVM.

Where JAVA is Being Used?

Earlier Java was only used to design and program small computing devices, but it was
later adopted as one of the platform-independent programming languages, and now according to
Sun, 3 billion devices run Java.
Java is one of the most important programming languages in today's IT industries.

 JSP - In Java, JSP (Java Server Pages) is used to create dynamic web pages, such as in
PHP and ASP.

 Applets - Applets are another type of Java programs that are implemented on Internet
browsers and are always run as part of a web document.

 J2EE - Java 2 Enterprise Edition is a platform-independent environment that is a set of


different protocols and APIs and is used by various organizations to transfer data between
each other.
 JavaBeans - This is a set of reusable software components that can be easily used to
create new and advanced applications.

 Mobile - In addition to the above technology, Java is widely used in mobile devices
nowadays, many types of games and applications are being made in Java.

Types of JAVA Applications

1. Web Application - Java is used to create server-side web applications. Currently,


Servlet, JSP, Struts, JSF, etc. technologies are used.

2. Standalone Application - It is also known as the desktop application or window-based


application. An application that we need to install on every machine or server such as
media player, antivirus, etc. AWT and Swing are used in java for creating standalone
applications.

3. Enterprise Application - An application that is distributed in nature, such as banking


applications, etc. It has the advantage of high-level security, load balancing, and
clustering. In Java, EJB is used for creating enterprise applications.

4. Mobile Application - Java is used to create application software for mobile devices.
Currently, Java ME is used for building applications for small devices, and also Java is a
programming language for Google Android application development.

Popular JAVA Editors

You will need a text editor to write Java programs. There is even more sophisticated IDE
available in the market. But for now, you can consider one of the following:
Object-Oriented Programming

 Notepad - On Windows machine, you can use any simple text editor like Notepad
(Recommended for this tutorial), TextPad.

 Netbeans - is a Java IDE that is open source and free which can be downloaded
from http://www.netbeans.org/index.html

 Eclipse - is also a java IDE developed by the Eclipse open source community and can be
downloaded from http://www.eclipse.org/

EVOLUTIONS OF JAVA

History of Java programming language is usually associated with origin predates of the
web. James Gosling, Patrick Naughton, Chris Warth, Mike Sheridan, and Ed Frank initiated the
Java language project in June 1991. The idea was to develop a language which was platform-
independent and which could create embedded software for consumer electronic devices. It took
18 months to develop and had an initial name as Oak which was renamed to Java in 1995, due to
copyright issues.

Java originally developed by James Gosling at Sun Microsystems(which has since merged into
Oracle Corporation) and released in 1995. JDK 1.0 released in (January 23, 1996).Java SE
10 is a current stable release of Java, and many other previous Java versions are also available.

JDK1.0 23 Jan 1996

JDK1.1 19 Feb 1997

J2SE 1.2 8 Dec 1998

J2SE 1.3 8 May 2000

J2SE 1.4 6 Feb 2002

J2SE 5.0 30 Sept 2004

Java SE 6 11 Dec 2006

Java SE 7.0 28 July 2011

Java SE 8.0 18 March 2014

Java SE 9.0 Sept 2017

Java SE 10 (18.3) 2018

Java is an object-oriented programming (OOP) language. What is OOP? The world


around us is made up of objects, such as people, automobiles, buildings, streets, adding machines,
Object-Oriented Programming

papers, and so forth. Each of these objects has the ability to perform certain actions, and each of
these actions has some effect on some of the other objects in the world. OOP is a programming
methodology that views a program as similarly consisting of objects that interact with each other
by means of actions. Object-oriented programming has its own specialized terminology. The
objects are called, appropriately enough, objects. The actions that an object can take are called
methods. Objects of the same kind are said to have the same type or, more often, are said to be in
the same class.
NOTABLE FEATURES OF JAVA:

 Object-Oriented - Java supports the features of object-oriented programming. Its object


model is simple and easy to expand. In Java, everything is an Object. Java can be easily
extended since it is based on the Object model.

 Platform independent - C and C++ are platform dependency languages hence the
application programs written in one Operating system cannot run in any other Operating
system, but in platform independence language like Java application programs written in
one Operating system can able to run on any Operating system.

 Simple - Java has included many features of C / C ++, which makes it easy to
understand.

 Secure - Java provides a wide range of protection from viruses and malicious
programs. It ensures that there will be no damage and no security will be broken.

 Portable - Java provides us with the concept of portability. Running the same program
with Java on different platforms is possible.

 Robust - During the development of the program, it helps us to find possible mistakes as
soon as possible.

 Multi-threaded - The multithreading programming feature in Java allows you to write a


program that performs several different tasks simultaneously.

 Distributed - Java is designed for distributed Internet environments as it manages the


Internet.

OOP Concepts

1. Object Oriented Programming Features

 Abstraction
 Encapsulation
 Inheritance
 Polymorphism

There are four main OOP concepts in Java. These are:

 Abstraction. Abstraction means using simple things to represent complexity. We all


know how to turn the TV on, but we don’t need to know how it works in order to enjoy it.
In Java, abstraction means simple things like objects, classes, and variables represent
more complex underlying code and data. This is important because it lets avoid repeating
the same work multiple times.
Object-Oriented Programming

 Encapsulation. This is the practice of keeping fields within a class private, then
providing access to them via public methods. It’s a protective barrier that keeps the data
and code safe within the class itself. This way, we can re-use objects like code
components or variables without allowing open access to the data system-wide.

 Inheritance. This is a special feature of Object Oriented Programming in Java. It lets


programmers create new classes that share some of the attributes of existing classes. This
lets us build on previous work without reinventing the wheel.

 Polymorphism. This Java OOP concept lets programmers use the same word to mean
different things in different contexts. One form of polymorphism in Java is method
overloading. That’s when different meanings are implied by the code itself. The other
form is method overriding. That’s when the different meanings are implied by the values
of the supplied variables.

JAVA PROGRAM STRUCTURE

A Java program involves the following sections:

 Documentation Section
 Package Statement
 Import Statements
 Interface Statement
 Class Definition
 Main Method Class

Section Description
Documentation You can write a comment in this section. Comments are beneficial for
Section the programmer because they help them understand the code. These
are optional, but we suggest you use them because they are useful to
understand the operation of the program, so you must write comments
within the program.
Package statement You can create a package with any name. A package is a group of
classes that are defined by a name. That is, if you want to declare many
classes within one element, then you can declare it within a package. It
is an optional part of the program, i.e., if you do not want to declare
any package, then there will be no problem with it, and you will not
get any errors. Here, the package is a keyword that tells the compiler
that package has been created.
It is declared as:

package package_name;
Import statements This line indicates that if you want to use a class of another package,
then you can do this by importing it directly into your program.
Example:
import calc.add;
Interface statement Interfaces are like a class that includes a group of method declarations.
It's an optional section and can be used when programmers want to
implement multiple inheritances within a program.
Class Definition A Java program may contain several class definitions. Classes are the
main and essential elements of any Java program.
Main Method Class Every Java stand-alone program requires the main method as the
Object-Oriented Programming

starting point of the program. This is an essential part of a Java


program. There may be many classes in a Java program, and only one
class defines the main method. Methods contain data type declaration
and executable statements.

Here is an example of the Hello Java program to understand the class structure and
features. There are a few lines in the program, and the primary task of the program is to
print Hello Java text on the screen.

A Simple Java Program to Print “Hello Java”

Example:

//Name of this file will be "Hello.java"

public class Hello


{
/*
Description:
Writes the words "Hello Java" on the screen */
public static void main(String[] args)
{
System.out.println("Hello Java");
}
}

Program Output:

Hello Java

Here are the most important points to note about the Java programs:
 You have to keep in mind that, Java code is case sensitive.
 To write a Java program, you must have to define class first.
 The name of the class in Java (which holds the main method) is the name of the
Java program, and the same name will be given in the filename. As mentioned
above in the sample program; The name of the class is "Hello" in which the main
method is, then this file will be named "Hello.Java".

Let’s Look into Various Parts of the written JAVA program:

public class Hello  This creates a class called Hello.


 All class names must start with a capital letter.
 The public word means that it is accessible from any other
classes.

/* Comments */  The compiler ignores comment block. Comment can be used


anywhere in the program to add info about the program or
code block, which will be helpful for developers to
understand the existing code in the future easily.
Braces  Two curly brackets {...} are used to group all the commands,
so it is known that the commands belong to that class or
method.
Object-Oriented Programming

public static void main  When the main method is declared public, it means that it
can also be used by code outside of its class, due to which
the main method is declared public.
 The word static used when we want to access a method
without creating its object, as we call the main
method, before creating any class objects.
 The word void indicates that a method does not return a
value. main() is declared as void because it does not return a
value.
 main is a method; this is a starting point of a Java program.
You will notice that the main method code has been moved to some
spaces left. It is called indentation which used to make a program
easier to read and understand.

String[] args  It is an array where each element of it is a string, which has
been named as "args". If your Java program is run through
the console, you can pass the input parameter, and main()
method takes it as input.
System.out.println();  This statement is used to print text on the screen as output,
where the system is a predefined class, and out is an object
of the PrintWriter class defined in the system. The
method println prints the text on the screen with a new
line. You can also use print() method instead of println()
method. All Java statement ends with a semicolon.
Java Interfaces / Environment

1) THE JAVA VIRTUAL MACHINES (JVM)

The Java Virtual Machine is called JVM, is an abstract computing machine or


virtual machine interface that drives the java code.

When we talk about the Java applications, then it works only on those
machines which have JVM.

What is JVM?
 JVM, i.e., Java Virtual Machine.
 JVM is the engine that drives the Java code.
 Mostly in other Programming Languages, compiler produce code for a
particular system but Java compiler produce Bytecode for a Java Virtual
Machine.
 When we compile a Java program, then bytecode is generated. Bytecode is
the source code that can be used to run on any platform.
 Bytecode is an intermediary language between Java source and the host
system.
 It is the medium which compiles Java code to bytecode which gets
interpreted on a different machine and hence it makes it Platform/Operating
system independent.

Diagram of JVM
Object-Oriented Programming

JVM generates a .class(Bytecode) file, and that file can be run in any OS,
but JVM should have in OS because JVM is platform dependent.

Platform Independent

Java is called platform independent because of Java Virtual Machine. As different


computers with the different operating system have their JVM, when we submit a .class file to
any operating system, JVM interprets the bytecode into machine level language.

 JVM is the main component of Java architecture, and it is the part of the JRE (Java
Runtime Environment).
 A program of JVM is written in C Programming Language, and JVM is Operating
System dependent.
 JVM is responsible for allocating the necessary memory needed by the Java program.
 JVM is responsible for deallocating memory space.

2) JAVA SE DEVELOPMENT KIT

JDK (Java SE Development Kit) Includes a complete JRE (Java Runtime


Environment) plus tools for developing, debugging, and monitoring Java applications.
JDK is required to build and run Java applications and applets.

JDK tools divided into five categories:


a) Basic Tools
b) Remote Method Invocation (RMI) Tools
c) Internationalization Tools
d) Security Tools
e) Java IDL Tools

3) JAVA Runtime Environment (JRE)

JRE stands for Java Runtime Environment which is used to provide an


environment at runtime. It is the cause of implementation of JVM (as discussed earlier).
Object-Oriented Programming

It contains a set of supporting libraries in combination with core classes and various other
files that are used by JVM at runtime. JRE is a part of JDK (Java Development
Toolkit) but can be downloaded separately.

JRE is a set of software tools for the development of Java applications.

You need JRE to execute your program, which includes two things:

 JVM
 Java Library
o Static - Functions that are required at compile time.
o Dynamic - Functions that are required at runtime and not at compile
time.

In detail, the JRE consists of various components; these are listed below:

 Java Web Start and Java Plug-in.


 User Interface Toolkit, which includes Abstract Window Toolkit (AWT), Swing,
Image Input / Output, Accessibility, drag, and drop, etc.
 Other different base libraries, including Input/Output, extension mechanisms,
beans, JMX, JNI, networking, override mechanisms, etc.
 Lang and util base libraries which include lang and util, management, versioning,
collections, etc.
 Integration libraries, which includes Interface Definition Language (IDL), Java
Database Connectivity (JDBC), Java Naming and Directory Interface (JNDI),
Remote Method Invocation (RMI).

Recommended Learning Materials and Resources


To supplement the lesson in this module, you may visit the following links:
 https://www.programiz.com/java-programming
 https://www.javatpoint.com
 https://beginnersbook.com/2017
 https://www.w3schools.com/java

Flexible Teaching Learning Modality (FTLM) adapted

In this lesson, Teaching and learning is mediated through the use of technology like print,
audio, video and the internet. Students interact with their instructors and each other through
virtual classrooms, email, and web conferencing. For the online modality, the Virtual Classroom
shall be used for the purpose of delivering a lecture and allowing a synchronous discussion with
the students. For the remote modality, Self-directed (SeDI) a learning management system shall
be used to upload the module and to allow asynchronous discussion with the students. This will
also be used as platform for the submission of the requirements.
Object-Oriented Programming

ASSESSMENT TASK

1. The Java language is


a. Interpreted at runtime
b. Compiled to obtain executable target files.
c. Designed for recursive string processing
d. Designed for recursive algorithm processing

2. The Java language is designed to:


a. Run on a simulated Java machine
b. Run directly on Intel microprocessor
c. Designed for computing architectures
d. All of the above

3. The Java language will run


a. On any computer where Java simulated machine is installed
b. In any computer attached to the Internet
c. On any computer with web browser installed
d. On any computer which will also run C++

4. The Java language is:


a. An object-oriented programming language
b. A structured programming language
c. A procedural programming language
d. A stack programming language

5. The Java program was designed:


a. To create event driven programs with graphical interfaces
b. To unify all different approaches to object orientation.
c. To provide a learning tool for beginning programmers.
d. To force programmers to implement all needed program elements
themselves.

II. Answer the following questions being asked.

 What are the key features of object-oriented programming?


 How is an object different from a class?
 How is abstraction different from encapsulation?
 What is object-oriented programming?
 Why did it evolve?
 How is it different from structured programming?
 Illustrate the JVM Chart and give explanations of the diagram
Object-Oriented Programming

 Enumerate the important note in Java programming.


 Identify the Various Parts of the written JAVA program and

References:
1. https://www.programiz.com/java-programming
2. https://www.javatpoint.com
3. https://beginnersbook.com/2017
4. https://www.w3schools.com/java
5. https://www.geeksforgeeks.org
6. https://www.tutorialspoint.com/java

You might also like