0% found this document useful (0 votes)
10 views

Lecture 1.1 - Introducing Java

1. The document introduces the Java programming language course, covering its history, importance of object-oriented programming, Java as an OOP language, the Java Virtual Machine architecture, and a basic "Hello World" program. 2. It discusses how Java was created in the early 1990s at Sun Microsystems to be a platform-independent language and the evolution of other programming languages. 3. Object-oriented programming is described as organizing programs around objects that have state and behavior, addressing limitations of earlier procedural models. This document provides an overview of the key topics to be covered in the Java course.

Uploaded by

ayan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lecture 1.1 - Introducing Java

1. The document introduces the Java programming language course, covering its history, importance of object-oriented programming, Java as an OOP language, the Java Virtual Machine architecture, and a basic "Hello World" program. 2. It discusses how Java was created in the early 1990s at Sun Microsystems to be a platform-independent language and the evolution of other programming languages. 3. Object-oriented programming is described as organizing programs around objects that have state and behavior, addressing limitations of earlier procedural models. This document provides an overview of the key topics to be covered in the Java course.

Uploaded by

ayan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Introducing Java

Course Code: CSC 1205 Course Title: Object Oriented Programming 1

Dept. of Computer Science


Faculty of Science and Technology

Lecturer No: 1 Week No: 1 Semester: Summer 21-22


Lecturer: Mazid-Ul-Haque, [email protected]
Lecture Outline

1. History of Programming Languages


2. Importance of OOP
3. Java as OOP Language
4. JVM Architecture
5. Hello World Program
History of Programming Languages
What is Programming Language

“Instead of imagining that our main task is to instruct a computer what to do, let
us concentrate rather on explaining to human beings what we want a computer
to do.” - Donald Knuth

A programming language is an artificial language that can be used to control the


behavior of a machine, particularly a computer. Programming languages, like
human languages, are defined using syntactic and semantic rules, to determine
structure and meaning, respectively.
History of Programming Languages
Evolution of Programming Languages

Epoch Description Languages


1950’s Creation of high-level languages Assembly, Fortran

1960’s Expansion of specialized languages Simula, Lisp, Cobol


Duel between structured programming with
1970’s C, Pascal
Pascal and efficiency of C language
1980’s Experimenting other ways including objects Smalltalk, C++
Generalization of object-oriented programming Java, Perl, Python,
1990’s
with the performance of microcomputers PHP
2000’s Internet Programming C#, Scala
2010’s Concurrency and asynchronicity JavaScript, Go
History of Programming Languages
The Creation of Java

• Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed


Frank, and Mike Sheridan at Sun Microsystems, Inc. in 1991.
• It took 18 months to develop the first working version.
• This language was initially called Oak but was renamed Java in 1995.
• The primary motivation was the need for a platform-independent language,
not the internet.
Importance of OOP
What is an Object

• Objects are key to understanding object-oriented technology.


• Real-world objects share two characteristics: They all have state and behavior.

• Example:
• Dogs have state (name, color, breed, hungry) and behavior (barking,
fetching, wagging tail)
• Bicycles also have state (current gear, current pedal cadence, current
speed) and behavior (changing gear, changing pedal cadence, applying
brakes)
Importance of OOP
What is OOP

Object Oriented Programming (OOP) is a programming methodology that helps


organize complex programs using inheritance, encapsulation, and
polymorphism.
Importance of OOP
Why OOP

• Throughout the history of programming, the increasing complexity of


programs has driven the need for better ways to manage complexity.
• Object Oriented Programming (OOP) was developed as there were limitations
in earlier approaches.
• Process-oriented model was one of the earlier approaches to Object-oriented
programming
• To clearly understand the importance of object-oriented programming, we
need to know about the process-oriented model
Importance of OOP
Why OOP (Process-Oriented Model)

All computer programs consists of two elements: a) code (what is happening) b)


data (who is being affected)

Process-Oriented Model:
 This approach characterizes a program as a series of linear steps (that is,
code).
 In this model, programs are typically organized around code. This approach
can be thought of as code acting on data.
 Procedural languages such as C employ this model to considerable success.
 In procedural programming, program is divided into small parts called
functions.
 Procedural programming follows top down approach.
 In procedural programming, function is more important than data.
Importance of OOP
Why OOP (Process-Oriented Model)

 In multi-function program, important data items are placed as global so that


they may be accessed by all functions
 Procedural programming is based on unreal world.
Importance of OOP
Why OOP (Drawbacks of Process-Oriented Model)

 Problems with this approach appear as programs grow larger and more
complex.
 As function has complete access to the global variables, it is possible that new
programmer can corrupt the data accidentally by creating functions.
 Data is exposed to whole program, so no security for data.
 In large program it is very difficult to identify what data is used by which
function.
 Difficult to relate with real world objects.
 Difficult to create new data types reduces extensibility.
 Importance is given to the operation on data rather that the data.
Importance of OOP
Why OOP (Object-Oriented Programming)

 Object-oriented programming organizes a program around its data (that is,


objects) and a set of well-defined interfaces to that data.
 An object-oriented program can be characterized as data controlling access to
code.
 In OOP, problem is divided into the number of entities called objects and then
builds data and methods around these objects.
 It binds the data more closely to the method that operate on it and protects it
from accidental modification.
 Data of an object can be accessed only by the methods associated with the
object.
 Follows bottom up approach.
 Increases code reusability and maintainability.
Importance of OOP
Why OOP is Important

 Modularity for easier troubleshooting.


 Reuse of code through inheritance.
 Flexibility through polymorphism.
 Effective problem solving.
Java as OOP Language
Why Java is Object Oriented

 It is not possible to code in java without class and object. Even to write a
single hello world program, we need to declare a class.
 Java supports encapsulation.
 Java supports abstraction.
 Java supports inheritance.
 Java supports polymorphism.
JVM Architecture
Introduction to JVM

 JVM(Java Virtual Machine) acts as a run-time engine to run Java applications.


 It converts Java bytecode into machines language
 JVM is a part of JRE(Java Runtime Environment).
JVM Architecture
How JVM Works

 In the Java programming language, all source code is first written in plain text
files ending with the .java extension.
 Those source files are then compiled into .class files by the javac compiler.
 A .class file does not contain code that is native to your processor; it instead
contains bytecodes—the machine language of the Java Virtual Machine (Java
VM).
 The java launcher tool then runs application with an instance of the Java
Virtual Machine.
JVM Architecture
Why Java is Platform Independent

 The meaning of platform-independent is that the java compiled code(byte


code) can run on all operating systems.
 The Java VM is available on many different operating systems.
 As a result, the same .class files can run on Microsoft Windows, Linux, Mac OS
and so on.
Hello World Program
Basic Hello World Program

 Create a HelloWorld.java source file.


 Write the following code in the source file.
Hello World Program
How to Execute Hello World Program

 To compile HelloWorld.java, use the compiler. If successful, it will produce a


file called HelloWorld.class in the same directory.

> javac HelloWorld.java

 To execute, run the Java VM and include the name of the class which contains
the "main" method as the first command line parameter.

> java HelloWorld


Books

1. Java The Complete Reference- Ninth Edition by Herbert Schildt


2. Head First Java, By Kathy Sierra and Bert Bates
References

• https://www.cs.mcgill.ca/~rwest/wikispeedia/wpcd/wp/p/Progra
mming_language.htm
• https://www.scriptol.com/programming/history.php
• https://docs.oracle.com/javase/tutorial/

You might also like