SlideShare a Scribd company logo
Introduction to JAVA
Md. Tanvir Hossain
Student, Dept of CSE
Daffodil International University
1
Features of Java : Simple
 Intentionally created to be syntactically similar to C/C++
 Eliminate traditionally troublesome features of C/C++
• Pointer arithmetic (no troublesome * and &)
• Multiple inheritance
• Implicit type coercions // if (1) {x = 1 ;} is not well-formed
• Explicit memory management
• Preprocessor
2
Features of Java : Simple
 Eliminate features of C/C++
• struct, typedef,union
• generic, enum (both recovered since jdk5.0)
• (Programmer controlled) operator overloading (but preserving
method overloading)
 Features included as part of base language:
• Threads
• Exception handling
• reflection
3
Features of Java : Object Oriented
 Java is inherently object-oriented.
• Although many object-oriented languages began strictly as
procedural languages, Java was designed from the start to be
object-oriented.
 Object-oriented programming (OOP) is a popular
programming approach that is replacing traditional
procedural programming techniques.
4
Features of Java: Object Oriented
 One of the central issues in software development is how to
reuse code.
• Object-oriented programming provides great flexibility,
modularity, clarity, and reusability through encapsulation,
inheritance, and polymorphism.
5
What is object-oriented ?
 Systems are built from sets of classes
 Classes are instantiated at runtime to give objects
 Objects communicate via messages passing (i.e., method or
function invocation)
 (In java) everything is part of a class
6
 Supported OO Concepts:
• Data abstraction and Encapsulation
• Inheritance
• Polymorphism
– dynamic binding - overriding
– overloading
– generics
 Logical cluster of classes == package
7
Features of Java: Object Oriented
Features of Java : Distributed
 Distributed computing involves several computers working
together on a network.
 Java is designed to make distributed computing easy.
 Since networking capability is inherently integrated into
Java, writing network programs is like sending and
receiving data to and from a file.
8
Features of Java : Distributed
 Network programming is supported by built in JDK class
library:
• TCP sockets ,UDP packets ,IP addresses
• URLs ,RMI (Remote Method Invocation)
• Web Service
 Security features designed into language
9
 Language implementation
• Compiler – produce machine code
– Ex: Fortran, Cobol, C, C++
• Interpreter – execute source or compiled instructions on a virtual
machine
– Ex: Scheme, Haskell, Python., Java
 Hybrid compilation/interpretation : Java
10
Features of Java : Interpreted Language
 The Java Virtual Machine (JVM)
java code byte code (machine independent)
[ just-in-time compilation native code ] execution
 We need an interpreter(JVM) to run Java programs.
• The bytecode is machine-independent and can be executed on any
machine that has a Java interpreter, which is the Java Virtual
Machine (JVM).
11
Features of Java : Interpreted Language
compile
 characteristics of Java
• Strongly-typed language (cf Smalltalk and VisualBasic)
• Compile-time and runtime checking
• No pointer arithmetic
• Exception handling
• Automatic memory management
12
Features of Java : Robust
 Java compilers can detect many problems that would first
show up at execution time in other languages.
 Java eliminated certain types of error-prone programming
constructs found in other languages.
 Runtime exception-handling feature provides
programming support for robustness.
13
Features of Java : Robust
 Designed with security in mind.
• Java implements several security mechanisms to protect your
system against harm caused by stray programs.
• Allow users to download untrusted code over a network and run it in a
secure environment in which it cannot do any harm.
 Configurable security levels and restrictions.
14
Features of Java : Secure
 Subjected to intense scrutiny by security experts with
[potentially serious ] bugs found and fixed.
• become a big news if new bugs found!!
• A recent security flaw(2012/08) (0-day flaw)
 One of the best mainstream platforms with the strongest
security guarantee.
15
Features of Java : Secure
 Byte-codes are architecture neutral
• Write once, run anywhere
• With a Java Virtual Machine (JVM), you can write one program
that will run on any platform.
 Performance suffers somewhat by using bytecodes
16
Features of Java : Architecture Neutral
 Source code :
• Primitive type sizes are explicit - not architecture dependent
• Strings and characters are (16-bit) Unicode compliant
– easier for internationalization.
 Byte code:
• run everywhere where a JVM is available
 User experience :
• GUI libraries give a native graphic library-independent mechanism
for creating quality graphical interfaces (sort of)
• "They gave us a library that is good for writing programs that look
equally mediocre on the different systems."
17
Features of Java : Portable
 Interpreting leads to quicker development cycle
 Depends what you compare it to
• "Slightly faster than VB" - (Core Java, page 9)
• JITC(Just-In-Time Compiler) help greatly in this respect
• Sun’s Java HotSpot is Newest high performace JIT compiler.
 Can use native code for mission-critical performance
sections of code
• JNI: Java Native Interface
• Sacrifice portability.
18
Features of Java : High Performance
 Based on well-known 20 year old Hoare monitor
synchronization
 Thread support built into language
 Thread synchronization primitives supplied
 Garbage collector runs permanently as a low priority
background thread
 Issue:
• Still hard to use right for general programmers:
• New package java.util.concurrency and other extensions added
since jdk5 allow easier and correct use of threads.
19
Features of Java : Multithreaded
 Class linking, layout, name resolution and object references
not resolved until run-time
 Runtime Type Information (RTTI) available
• Can check the type of objects at run-time
• java.reflect.* package
 Class class for dynamic instantiation
• Can create objects of types unkown until runtime.
String name = getSpecies(); // get a name of a class
Object p = Class.forName(name).newInstance();
if(p instanceof Hen) {…}
else if(p instanceof Coq) { …}
else {… }
20
Features of Java : Dynamic
 Green Project (1990)
• need a small PL for developing consumer device operating software
• Requirements: small size, robust, portable, extremely reliable ,real-
time performance
 Oak // the resulting language
• Originally used C++, then realized a new language was needed
• Original requirements same as for current language
 Java (1993) // OAK was renamed Java
• Intended market never eventuated (no technology/product sold)
• WWW starting to takeoff
• Language design "based on" many current OO languages (e.g.,
C++, Eiffel, Smalltalk, Cedar/Mesa, Objective C)
• 1995/5/23 Sun launched Java
 JDK 1.0 released early 1996/1/23 ( 211 classes / 8 pkgs) 21
Early history of Java
Evolution of the Java Language
22
Java Jargon
23
How JAVA code are structured
 A java application consists of
• many packages
• Some from JRE (built-ins)+ some from 3rd party + your own ]
 A package consists of
• 0 or more classes
• 0 or more subpackages
 A java source file xxx.java is called a compilation unit,
which may
• contain multiple java class definitions and
• may be compiled into multiple java byte code (***.class ).
24
Package and class naming
 A class or package has two names:
• simpleName
• fully qualified name = parentPackageName . simpleName
• packageName = parentPackageName . simpleName
• For package, we use only its full name.
– Ex:
– java.lang.String
– javax.swing.JButton
25
Package and class naming
 The package/subpackage/(*.class, *.java) structure is not
only logically analogous to directory/ subdirectory/ file in
OS file system but in fact they are stored physically in file
system in this way.
• Namely, if package p is located in a directory d then subpackage p.q
of p would be stored in subdirecty q of d, and class p.A of p would
be stored in file named A.class or A.java.
26

More Related Content

PDF
Introduction to java (revised)
PPSX
Introduction of java
PPTX
Introduction to java
PPTX
Introduction to java
PPTX
Core java complete ppt(note)
PPTX
Introduction to Basic Java Versions and their features
PDF
Basic Java Programming
PPTX
Introduction to java
Introduction to java (revised)
Introduction of java
Introduction to java
Introduction to java
Core java complete ppt(note)
Introduction to Basic Java Versions and their features
Basic Java Programming
Introduction to java

What's hot (20)

PPTX
Introduction to spring boot
PPTX
Introduction To C#
PDF
Basic i/o & file handling in java
PPT
Java EE Introduction
PPTX
Features of JAVA Programming Language.
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
PPTX
Coding standards for java
PPT
Maven Introduction
PPTX
Intro to Java
PDF
The New JavaScript: ES6
PDF
React & GraphQL
PPTX
Understanding REST APIs in 5 Simple Steps
PDF
Introduction to Java Programming
PPTX
Basics of JAVA programming
PDF
Php introduction
PPTX
An intro to GraphQL
PDF
TypeScript - An Introduction
PPTX
Backend Programming
PPTX
ppt of web development for diploma student
PPTX
core java
Introduction to spring boot
Introduction To C#
Basic i/o & file handling in java
Java EE Introduction
Features of JAVA Programming Language.
Basic Concepts of OOPs (Object Oriented Programming in Java)
Coding standards for java
Maven Introduction
Intro to Java
The New JavaScript: ES6
React & GraphQL
Understanding REST APIs in 5 Simple Steps
Introduction to Java Programming
Basics of JAVA programming
Php introduction
An intro to GraphQL
TypeScript - An Introduction
Backend Programming
ppt of web development for diploma student
core java
Ad

Similar to Introduction to JAVA (20)

PDF
Java Concepts and Features-Programming in Java
PDF
Lec 3 01_aug13
PPTX
Java
PPTX
java basics concepts and the keywords needed
PPTX
Chapter-1 Introduction.pptx
PPTX
Java Programming
PDF
itft-Java evolution
PPTX
Chapter 1 (1).pptx
PPTX
Module1_htryjtjhkrhdegtfhsfhrdgfhpart1.pptx
PPTX
UNIT 1.pptx
PPTX
Features of java Part - 3
PDF
Java programming Evolution-OverviewOfJava.pdf
PPTX
Unit1 introduction to Java
PDF
0f0cef_1dac552af56c4338ab0672859199e693.pdf
PPTX
PPT
Introduction to Java Programming, Basic Structure, variables Data type, input...
PPTX
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
Java Concepts and Features-Programming in Java
Lec 3 01_aug13
Java
java basics concepts and the keywords needed
Chapter-1 Introduction.pptx
Java Programming
itft-Java evolution
Chapter 1 (1).pptx
Module1_htryjtjhkrhdegtfhsfhrdgfhpart1.pptx
UNIT 1.pptx
Features of java Part - 3
Java programming Evolution-OverviewOfJava.pdf
Unit1 introduction to Java
0f0cef_1dac552af56c4338ab0672859199e693.pdf
Introduction to Java Programming, Basic Structure, variables Data type, input...
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
Ad

More from Md. Tanvir Hossain (14)

PPTX
Automated train
PPTX
PPTX
Adjusting the accounts
PPTX
Segmentation
PPTX
Linux file system
PPTX
Normalization
PPTX
Application of interpolation in CSE
PPTX
Internet(Internetwork)
PPTX
Basic Biocomputing
PPTX
Intel core i3 processor
PPTX
Satellite communication and it's future
PPTX
Introduction to Object Oriented Programming
PPTX
Java interface
PPTX
Java exception handling
Automated train
Adjusting the accounts
Segmentation
Linux file system
Normalization
Application of interpolation in CSE
Internet(Internetwork)
Basic Biocomputing
Intel core i3 processor
Satellite communication and it's future
Introduction to Object Oriented Programming
Java interface
Java exception handling

Recently uploaded (20)

PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
01-Introduction-to-Information-Management.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Complications of Minimal Access Surgery at WLH
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Pre independence Education in Inndia.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Microbial disease of the cardiovascular and lymphatic systems
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
VCE English Exam - Section C Student Revision Booklet
01-Introduction-to-Information-Management.pdf
PPH.pptx obstetrics and gynecology in nursing
Complications of Minimal Access Surgery at WLH
102 student loan defaulters named and shamed – Is someone you know on the list?
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Module 4: Burden of Disease Tutorial Slides S2 2025
Microbial diseases, their pathogenesis and prophylaxis
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Pre independence Education in Inndia.pdf

Introduction to JAVA

  • 1. Introduction to JAVA Md. Tanvir Hossain Student, Dept of CSE Daffodil International University 1
  • 2. Features of Java : Simple  Intentionally created to be syntactically similar to C/C++  Eliminate traditionally troublesome features of C/C++ • Pointer arithmetic (no troublesome * and &) • Multiple inheritance • Implicit type coercions // if (1) {x = 1 ;} is not well-formed • Explicit memory management • Preprocessor 2
  • 3. Features of Java : Simple  Eliminate features of C/C++ • struct, typedef,union • generic, enum (both recovered since jdk5.0) • (Programmer controlled) operator overloading (but preserving method overloading)  Features included as part of base language: • Threads • Exception handling • reflection 3
  • 4. Features of Java : Object Oriented  Java is inherently object-oriented. • Although many object-oriented languages began strictly as procedural languages, Java was designed from the start to be object-oriented.  Object-oriented programming (OOP) is a popular programming approach that is replacing traditional procedural programming techniques. 4
  • 5. Features of Java: Object Oriented  One of the central issues in software development is how to reuse code. • Object-oriented programming provides great flexibility, modularity, clarity, and reusability through encapsulation, inheritance, and polymorphism. 5
  • 6. What is object-oriented ?  Systems are built from sets of classes  Classes are instantiated at runtime to give objects  Objects communicate via messages passing (i.e., method or function invocation)  (In java) everything is part of a class 6
  • 7.  Supported OO Concepts: • Data abstraction and Encapsulation • Inheritance • Polymorphism – dynamic binding - overriding – overloading – generics  Logical cluster of classes == package 7 Features of Java: Object Oriented
  • 8. Features of Java : Distributed  Distributed computing involves several computers working together on a network.  Java is designed to make distributed computing easy.  Since networking capability is inherently integrated into Java, writing network programs is like sending and receiving data to and from a file. 8
  • 9. Features of Java : Distributed  Network programming is supported by built in JDK class library: • TCP sockets ,UDP packets ,IP addresses • URLs ,RMI (Remote Method Invocation) • Web Service  Security features designed into language 9
  • 10.  Language implementation • Compiler – produce machine code – Ex: Fortran, Cobol, C, C++ • Interpreter – execute source or compiled instructions on a virtual machine – Ex: Scheme, Haskell, Python., Java  Hybrid compilation/interpretation : Java 10 Features of Java : Interpreted Language
  • 11.  The Java Virtual Machine (JVM) java code byte code (machine independent) [ just-in-time compilation native code ] execution  We need an interpreter(JVM) to run Java programs. • The bytecode is machine-independent and can be executed on any machine that has a Java interpreter, which is the Java Virtual Machine (JVM). 11 Features of Java : Interpreted Language compile
  • 12.  characteristics of Java • Strongly-typed language (cf Smalltalk and VisualBasic) • Compile-time and runtime checking • No pointer arithmetic • Exception handling • Automatic memory management 12 Features of Java : Robust
  • 13.  Java compilers can detect many problems that would first show up at execution time in other languages.  Java eliminated certain types of error-prone programming constructs found in other languages.  Runtime exception-handling feature provides programming support for robustness. 13 Features of Java : Robust
  • 14.  Designed with security in mind. • Java implements several security mechanisms to protect your system against harm caused by stray programs. • Allow users to download untrusted code over a network and run it in a secure environment in which it cannot do any harm.  Configurable security levels and restrictions. 14 Features of Java : Secure
  • 15.  Subjected to intense scrutiny by security experts with [potentially serious ] bugs found and fixed. • become a big news if new bugs found!! • A recent security flaw(2012/08) (0-day flaw)  One of the best mainstream platforms with the strongest security guarantee. 15 Features of Java : Secure
  • 16.  Byte-codes are architecture neutral • Write once, run anywhere • With a Java Virtual Machine (JVM), you can write one program that will run on any platform.  Performance suffers somewhat by using bytecodes 16 Features of Java : Architecture Neutral
  • 17.  Source code : • Primitive type sizes are explicit - not architecture dependent • Strings and characters are (16-bit) Unicode compliant – easier for internationalization.  Byte code: • run everywhere where a JVM is available  User experience : • GUI libraries give a native graphic library-independent mechanism for creating quality graphical interfaces (sort of) • "They gave us a library that is good for writing programs that look equally mediocre on the different systems." 17 Features of Java : Portable
  • 18.  Interpreting leads to quicker development cycle  Depends what you compare it to • "Slightly faster than VB" - (Core Java, page 9) • JITC(Just-In-Time Compiler) help greatly in this respect • Sun’s Java HotSpot is Newest high performace JIT compiler.  Can use native code for mission-critical performance sections of code • JNI: Java Native Interface • Sacrifice portability. 18 Features of Java : High Performance
  • 19.  Based on well-known 20 year old Hoare monitor synchronization  Thread support built into language  Thread synchronization primitives supplied  Garbage collector runs permanently as a low priority background thread  Issue: • Still hard to use right for general programmers: • New package java.util.concurrency and other extensions added since jdk5 allow easier and correct use of threads. 19 Features of Java : Multithreaded
  • 20.  Class linking, layout, name resolution and object references not resolved until run-time  Runtime Type Information (RTTI) available • Can check the type of objects at run-time • java.reflect.* package  Class class for dynamic instantiation • Can create objects of types unkown until runtime. String name = getSpecies(); // get a name of a class Object p = Class.forName(name).newInstance(); if(p instanceof Hen) {…} else if(p instanceof Coq) { …} else {… } 20 Features of Java : Dynamic
  • 21.  Green Project (1990) • need a small PL for developing consumer device operating software • Requirements: small size, robust, portable, extremely reliable ,real- time performance  Oak // the resulting language • Originally used C++, then realized a new language was needed • Original requirements same as for current language  Java (1993) // OAK was renamed Java • Intended market never eventuated (no technology/product sold) • WWW starting to takeoff • Language design "based on" many current OO languages (e.g., C++, Eiffel, Smalltalk, Cedar/Mesa, Objective C) • 1995/5/23 Sun launched Java  JDK 1.0 released early 1996/1/23 ( 211 classes / 8 pkgs) 21 Early history of Java
  • 22. Evolution of the Java Language 22
  • 24. How JAVA code are structured  A java application consists of • many packages • Some from JRE (built-ins)+ some from 3rd party + your own ]  A package consists of • 0 or more classes • 0 or more subpackages  A java source file xxx.java is called a compilation unit, which may • contain multiple java class definitions and • may be compiled into multiple java byte code (***.class ). 24
  • 25. Package and class naming  A class or package has two names: • simpleName • fully qualified name = parentPackageName . simpleName • packageName = parentPackageName . simpleName • For package, we use only its full name. – Ex: – java.lang.String – javax.swing.JButton 25
  • 26. Package and class naming  The package/subpackage/(*.class, *.java) structure is not only logically analogous to directory/ subdirectory/ file in OS file system but in fact they are stored physically in file system in this way. • Namely, if package p is located in a directory d then subpackage p.q of p would be stored in subdirecty q of d, and class p.A of p would be stored in file named A.class or A.java. 26