KEMBAR78
OOP - Lecture02 - Introduction to Java.pptx
Lecture 02
Introduction to Java
Lecture Outline
• Evolution of Programming Languages
• Why Java?
• Java History
• Java Versions
• Java Features
• Java Procedure
• Revision of Programming Fundamentals Topics
What is a Program?
• A computer program is a sequence of instructions written to
perform a specified task for a computer.
The Evolution of Programming Language
• Machine Language: 1940’s
• Assembly Language: Early 1950’s
• Higher-Level Languages: Late 1950’s
• Fortran: scientific computation
• COBOL: business data processing
• Lisp: symbolic computation
• Today: Thousands of programming languages available
What is Programming?
• When we say “programming” we are actually referring to the
science of transforming our intentions in a high-level
programming language.
What is this course about?
• Learn programming in a high-level programming language.
• Programming has many paradigms
• Procedural
• Object-Oriented
• We will study Object-Oriented Programming using ‘Java’, a
popular high-level object-oriented programming language.
Non-structured Programming
e.g. Assembly Language, BASIC
• Advantages
– Low Level access
– High Optimization
– Shorter size programs
• Disadvantages
– Large programs highly complex
– Difficult to understand
– Repetition of code
a 100
mov ax,0002
mov bx,0004
add ax,bx
nop
Procedural/Structured Programming
e.g. C, Pascal
• Advantages
– Fast execution
– Small memory footprint (Size)
• Disadvantages
– Limited in Enhancement over the time
– Low reusability
– Difficult to Extended
– Less Dynamic architecture
Object Oriented Programming
e.g. C++, C#, Java etc
• Disadvantages
– Little Slow execution
– Little Big memory footprint (Size)
• Advantages
– Better Enhancement over the time
– High reusability
– Easy to Extended
– Better representation of real world problems
Why Java?
• It’s the current “hot” language
• Java mean “Cup of Coffee”
• It’s almost entirely object-oriented
• It has a vast library of predefined objects and operations
• It’s more platform independent
• This makes it great for web programming too (but that is beyond this
course)
• It’s more secure
• It isn’t C++
Java History (1 of 3)
• created in 1991
• by James Gosling et al. of Sun Microsystems.
• Initially called Oak, in honor of the tree outside Gosling's window,
its name was changed to Java because there was already a
language called Oak.
Java History (2 of 3)
• The term Java actually refers to more than just a particular
language like C or Pascal. Java encompasses several parts,
including:
• A high level language – Java language is a high level one that at a
glance looks very similar to C and C++ but offers many unique features
of its own.
• Java bytecode – A compiler, such as Sun's javac, transforms the Java
language source code to bytecode that runs in the JVM.
• Java Virtual Machine (JVM) – a program, such as Sun's java, that runs
on a given platform and takes the bytecode programs as input and
interprets them just as if it was a physical process executing machine
code.
Java History (3 of 3)
• Sun provides a set of programming tools such as javac, java and
others in a bundle that it calls a Java Software Development Kit
for each version of the language for different platforms such as
Windows, Linux, etc.
• Sun also provides a runtime bundle with just the JVM when the
programming tools are not needed.
Java Versions (1 of 2)
• Since its introduction in 1995, Sun has released a new version of the
Java language every two years or so.
• These new versions brought enhancements, new capabilities and fixes to
bugs.
• Till 2002, the versions were numbered 1.x, where x reached up till 4.
(Intermediate revisions were labeled with a third number - 1.x.y - as in
1.4.2.)
• After that all the versions were released with a whole number such as 5.0 or
6.
• The current version of Java is Java SE 17 (LTS) where SE refers to
Standard Edition (used for targeting workstations) and the LTS refers to
Long Term Support.
• Not all Java versions have LTS, so far only 3 have been released (2008,
2018 and 2021)
• Another newer version of Java SE 18 is expected to be released in
March 2022
Java Versions (2 of 2)
• The major editions of Java are:
• Java Card (for smart cards)
• Java Micro Edition (for limited resources environments)
• Java Standard Edition (for workstations)
• Java Enterprise Edition (for enterprises and internet environments)
Java Features
• Simple & Secure
• Object-Oriented
• Robust
• Restricts the programmer to find the mistakes early
• Performs compile-time (strong typing) and run-time (exception-handling)
checks
• Manages memory automatically
• Multithreaded
• Architecture-Neutral
• Interpreted and High-Performance
• Distributed
• Dynamic
Java Procedure
• The essential steps to creating and running Java programs go as
follows:
• Create a Java source code file
• Compile the source code
• Run the compiled code in any Java Virtual Machine.
Java Program Execution
Java Program Execution
• Manual – with text editor (notepad)
• Create the Java source code files (*.java)
• Use Command Line tools in the Java Software Development Kit (SDK).
• The SDK is provided by Sun for several platforms and includes a
number of tools, the most important of which are:
• javac – compiles Java source code files
• java – runs Java application programs
• appletviewer – tests applets independently of a browser
• Integrated Development Environment (IDE)
• NetBeans
• Borland JBuilder
• Eclipse
• Dr Java
• IntelliJ IDEA (My Favorite)
Revision (1 of 3)
• Decision Making Statements
• If-else
• Switch Case
• Loops
• For
• While
• Do-While
• Nested {{}}
Revision (2 of 3)
• Variables
• Strings in C/C++
• Arrays
• 1D
• 2D
• ND
Revision (3 of 3)
• Functions / Methods
• Declaration
• Definition
• Calling
• Overloading
• Passing Arguments
• By Value
• By reference in java?
Thank You 
Any Questions?

OOP - Lecture02 - Introduction to Java.pptx

  • 1.
  • 2.
    Lecture Outline • Evolutionof Programming Languages • Why Java? • Java History • Java Versions • Java Features • Java Procedure • Revision of Programming Fundamentals Topics
  • 3.
    What is aProgram? • A computer program is a sequence of instructions written to perform a specified task for a computer.
  • 4.
    The Evolution ofProgramming Language • Machine Language: 1940’s • Assembly Language: Early 1950’s • Higher-Level Languages: Late 1950’s • Fortran: scientific computation • COBOL: business data processing • Lisp: symbolic computation • Today: Thousands of programming languages available
  • 5.
    What is Programming? •When we say “programming” we are actually referring to the science of transforming our intentions in a high-level programming language.
  • 6.
    What is thiscourse about? • Learn programming in a high-level programming language. • Programming has many paradigms • Procedural • Object-Oriented • We will study Object-Oriented Programming using ‘Java’, a popular high-level object-oriented programming language.
  • 7.
    Non-structured Programming e.g. AssemblyLanguage, BASIC • Advantages – Low Level access – High Optimization – Shorter size programs • Disadvantages – Large programs highly complex – Difficult to understand – Repetition of code a 100 mov ax,0002 mov bx,0004 add ax,bx nop
  • 8.
    Procedural/Structured Programming e.g. C,Pascal • Advantages – Fast execution – Small memory footprint (Size) • Disadvantages – Limited in Enhancement over the time – Low reusability – Difficult to Extended – Less Dynamic architecture
  • 9.
    Object Oriented Programming e.g.C++, C#, Java etc • Disadvantages – Little Slow execution – Little Big memory footprint (Size) • Advantages – Better Enhancement over the time – High reusability – Easy to Extended – Better representation of real world problems
  • 10.
    Why Java? • It’sthe current “hot” language • Java mean “Cup of Coffee” • It’s almost entirely object-oriented • It has a vast library of predefined objects and operations • It’s more platform independent • This makes it great for web programming too (but that is beyond this course) • It’s more secure • It isn’t C++
  • 11.
    Java History (1of 3) • created in 1991 • by James Gosling et al. of Sun Microsystems. • Initially called Oak, in honor of the tree outside Gosling's window, its name was changed to Java because there was already a language called Oak.
  • 12.
    Java History (2of 3) • The term Java actually refers to more than just a particular language like C or Pascal. Java encompasses several parts, including: • A high level language – Java language is a high level one that at a glance looks very similar to C and C++ but offers many unique features of its own. • Java bytecode – A compiler, such as Sun's javac, transforms the Java language source code to bytecode that runs in the JVM. • Java Virtual Machine (JVM) – a program, such as Sun's java, that runs on a given platform and takes the bytecode programs as input and interprets them just as if it was a physical process executing machine code.
  • 13.
    Java History (3of 3) • Sun provides a set of programming tools such as javac, java and others in a bundle that it calls a Java Software Development Kit for each version of the language for different platforms such as Windows, Linux, etc. • Sun also provides a runtime bundle with just the JVM when the programming tools are not needed.
  • 14.
    Java Versions (1of 2) • Since its introduction in 1995, Sun has released a new version of the Java language every two years or so. • These new versions brought enhancements, new capabilities and fixes to bugs. • Till 2002, the versions were numbered 1.x, where x reached up till 4. (Intermediate revisions were labeled with a third number - 1.x.y - as in 1.4.2.) • After that all the versions were released with a whole number such as 5.0 or 6. • The current version of Java is Java SE 17 (LTS) where SE refers to Standard Edition (used for targeting workstations) and the LTS refers to Long Term Support. • Not all Java versions have LTS, so far only 3 have been released (2008, 2018 and 2021) • Another newer version of Java SE 18 is expected to be released in March 2022
  • 15.
    Java Versions (2of 2) • The major editions of Java are: • Java Card (for smart cards) • Java Micro Edition (for limited resources environments) • Java Standard Edition (for workstations) • Java Enterprise Edition (for enterprises and internet environments)
  • 16.
    Java Features • Simple& Secure • Object-Oriented • Robust • Restricts the programmer to find the mistakes early • Performs compile-time (strong typing) and run-time (exception-handling) checks • Manages memory automatically • Multithreaded • Architecture-Neutral • Interpreted and High-Performance • Distributed • Dynamic
  • 17.
    Java Procedure • Theessential steps to creating and running Java programs go as follows: • Create a Java source code file • Compile the source code • Run the compiled code in any Java Virtual Machine.
  • 18.
  • 19.
    Java Program Execution •Manual – with text editor (notepad) • Create the Java source code files (*.java) • Use Command Line tools in the Java Software Development Kit (SDK). • The SDK is provided by Sun for several platforms and includes a number of tools, the most important of which are: • javac – compiles Java source code files • java – runs Java application programs • appletviewer – tests applets independently of a browser • Integrated Development Environment (IDE) • NetBeans • Borland JBuilder • Eclipse • Dr Java • IntelliJ IDEA (My Favorite)
  • 20.
    Revision (1 of3) • Decision Making Statements • If-else • Switch Case • Loops • For • While • Do-While • Nested {{}}
  • 21.
    Revision (2 of3) • Variables • Strings in C/C++ • Arrays • 1D • 2D • ND
  • 22.
    Revision (3 of3) • Functions / Methods • Declaration • Definition • Calling • Overloading • Passing Arguments • By Value • By reference in java?
  • 23.