SlideShare a Scribd company logo
Java Programming Language
Objectives


                •   In this session, you will learn to:
                       Describe the key features of Java technology
                       Write, compile, and run a simple Java technology application
                       Describe the function of the Java Virtual Machine
                       Define garbage collection
                       List the three tasks performed by the Java platform that handle
                       code security
                       Define modeling concepts: abstraction, encapsulation, and
                       packages
                       Discuss why you can reuse Java technology application code
                       Define class, member, attribute, method, constructor, and
                       package
                       Use the access modifiers private and public as appropriate for
                       the guidelines of encapsulation


     Ver. 1.0                            Session 1                            Slide 1 of 31
Java Programming Language
Objectives (Contd.)


                Invoke a method on a particular object
                Use the Java technology Application Programming Interface
                online documentation




     Ver. 1.0                    Session 1                          Slide 2 of 31
Java Programming Language
Key Features of Java Technology


                A programming language
                A development environment
                An application environment
                A deployment environment

                Java Technology is used for developing both applets and
                applications.




     Ver. 1.0                     Session 1                        Slide 3 of 31
Java Programming Language
Primary Goals of the Java Technology


                Provides an easy-to-use language by:
                   Avoiding many pitfalls of other languages
                   Being object-oriented
                   Enables code streamlining
                Provides an interpreted environment for:
                   Improved speed of development
                   Code portability
                Loads classes dynamically, i.e., at the time they are actually
                needed
                Supports changing programs dynamically during runtime by
                loading classes from distinct sources
                Furnishes better security
                Enable users to run more than one thread of an activity


     Ver. 1.0                       Session 1                         Slide 4 of 31
Java Programming Language
Primary Features of the Java Technology


                The Java Virtual Machine (JVM™)
                Garbage collection
                The Java Runtime Environment (JRE)
                JVM tool interface




     Ver. 1.0                    Session 1           Slide 5 of 31
Java Programming Language
The Java Virtual Machine


                JVM provides definitions for the:
                   Instruction set (Central Processing Unit [CPU])
                   Register set
                   Class file format
                   Runtime stack
                   Garbage-collected heap
                   Memory area
                   Fatal error reporting mechanism
                   High-precision timing support




     Ver. 1.0                        Session 1                       Slide 6 of 31
Java Programming Language
Garbage Collection


                Garbage collection has the following characteristics:
                   Checks for and frees memory no longer needed, automatically.
                   Provides a system-level thread to track memory allocation.




     Ver. 1.0                       Session 1                           Slide 7 of 31
Java Programming Language
The Java Runtime Environment


               • The Java application environment performs as follows:




    Ver. 1.0                         Session 1                       Slide 8 of 31
Java Programming Language
JVM™ Tasks


               The JVM performs three main tasks:
                  Loads code – Performed by the class loader.
                  Verifies code – Performed by the bytecode verifier.
                  Executes code – Performed by the runtime interpreter.




    Ver. 1.0                       Session 1                              Slide 9 of 31
Java Programming Language
The Class Loader


                Loads all classes necessary for the execution of a program.
                Maintains classes of the local file system in separate
                namespaces.
                Avoids execution of the program whose bytecode has been
                changed illegally.




     Ver. 1.0                      Session 1                        Slide 10 of 31
Java Programming Language
The Bytecode Verifier


                All class files imported across the network pass through the
                bytecode verifier, which ensures that:
                   The code adheres to the JVM specification.
                   The code does not violate system integrity.
                   The code causes no operand stack overflows or underflows.
                   The parameter types for all operational code are correct.
                   No illegal data conversions (the conversion of integers to
                   pointers) have occurred.




     Ver. 1.0                       Session 1                          Slide 11 of 31
Java Programming Language
Java Technology Runtime Environment




     Ver. 1.0              Session 1   Slide 12 of 31
Java Programming Language
A simple Java Application


                Let see how to create a simple Java Application.




     Ver. 1.0                         Session 1                    Slide 13 of 31
Java Programming Language
The Analysis and Design Phase


                Analysis describes what the system needs to do:
                   Modeling the real-world, including actors and activities, objects,
                   and behaviors.
                Design describes how the system does it:
                   Modeling the relationships and interactions between objects
                   and actors in the system.
                Finding useful abstractions to help simplify the problem or
                solution.




     Ver. 1.0                        Session 1                              Slide 14 of 31
Java Programming Language
Declaring Java Technology Classes


                Basic syntax of a Java class:
                 <modifier>* class <class_name>
                 { <attribute_declaration>*
                   <constructor_declaration>*
                   <method_declaration>*
                 }
                Example:
                 public class MyFirstClass
                 { private int age;
                   public void setAge(int value)
                   { age = value;
                   }
                 }
     Ver. 1.0                 Session 1            Slide 15 of 31
Java Programming Language
Declaring Attributes


                Basic syntax of an attribute:
                 <modifier>* <type> <name> [ =
                 <initial_value>];
                Example:
                 public class MyFirstClass
                 {
                     private int x;
                     private float y = 10000.0F;
                     private String name = “NIIT";
                 }




     Ver. 1.0                  Session 1             Slide 16 of 31
Java Programming Language
Declaring Methods


                Basic syntax of a method:
                 <modifier>* <return_type> <name>
                 ( <argument>* ){         <statement>* }
                Example:
                 public class Dog
                 { private int weight;
                     public int getWeight()
                     { return weight;
                     }
                     public void setWeight(int newWeight)
                     { if ( newWeight > 0 )
                         { weight = newWeight;
                     } } }

     Ver. 1.0                  Session 1                Slide 17 of 31
Java Programming Language
Accessing Object Members


               To access object members, including attributes and
               methods, dot notation is used
                  The dot notation is: <object>.<member>
                  Examples:
                   d.setWeight(42);
                   d.weight = 42;           // only permissible if weight is public




    Ver. 1.0                        Session 1                              Slide 18 of 31
Java Programming Language
Class Representation Using UML


                • Class representation of MyDate class:

                     MyDate                       Class name

                     -day : int
                     -month : int                   Attributes
                     -year : int

                     +getDay()
                     +getMonth()
                     +getYear()                                  Methods
                     +setDay(int) : boolean
                     +setMonth(int) : boolean
                     +setYear(int) : boolean

     Ver. 1.0                         Session 1                            Slide 19 of 31
Java Programming Language
Abstraction


                Abstraction means ignoring the non-essential details of an
                object and concentrating on its essential details.




     Ver. 1.0                      Session 1                        Slide 20 of 31
Java Programming Language
Encapsulation


                Encapsulation provides data representation flexibility by:
                   Hiding the implementation details of a class.
                   Forcing the user to use an interface to access data.
                   Making the code more maintainable.




     Ver. 1.0                        Session 1                            Slide 21 of 31
Java Programming Language
Declaring Constructors


                •   A constructor is a set of instructions designed to initialize an
                    instance.
                •   Basic syntax of a constructor:
                     [<modifier>] <class_name> ( <argument>* )
                     { <statement>* }
                    Example:
                     public class Dog
                     { private int weight;
                         public Dog()
                         { weight = 42;
                         }
                     }


     Ver. 1.0                            Session 1                          Slide 22 of 31
Java Programming Language
The Default Constructor


                There is always at least one constructor in every class.
                If the programmer does not supply any constructor, the
                default constructor is present automatically.
                The characteristics of default constructor:
                 – The default constructor takes no arguments.
                 – The default constructor body is empty.
                 – The default constructor enables you to create object instances
                   with new xyz() without having to write a constructor.




     Ver. 1.0                        Session 1                           Slide 23 of 31
Java Programming Language
Source File Layout


                Basic syntax of a Java source file:
                 [<package_declaration>]
                 <import_declaration>*
                 <class_declaration>+
                For example, the VehicleCapacityReport.java file can be
                written as:
                 package shipping.reports;
                 import shipping.domain.*;
                 import java.util.List;
                 import java.io.*;
                 public class VehicleCapacityReport
                 { private List vehicles;
                    public void generateReport(Writer output)
                    {...} }


     Ver. 1.0                     Session 1                     Slide 24 of 31
Java Programming Language
Software Packages


               • Packages help manage large software systems.
               • Packages can contain classes and sub-packages.




    Ver. 1.0                      Session 1                       Slide 25 of 31
Java Programming Language
Software Packages (Contd.)


                Basic syntax of the import statement:
                 import
                 <pkg_name>[.<sub_pkg_name>]*.<class_name>;
                or
                 import <pkg_name>[.<sub_pkg_name>]*.*;
                Examples:
                import java.util.List;
                import java.io.*;
                import shipping.gui.reportscreens.*;
                The import statement does the following:
                  Precedes all class declarations
                  Tells the compiler where to find classes


     Ver. 1.0                       Session 1                Slide 26 of 31
Java Programming Language
Deployment


               In order to deploy an application without manipulating the
               user’s CLASSPATH environment variable, create an
               executable Java Archive (JAR) File.
               To deploy library code in a JAR file, copy the JAR file into
               the ext subdirectory of the lib directory in the main directory
               of the JRE.




    Ver. 1.0                       Session 1                           Slide 27 of 31
Java Programming Language
Using the Java Technology API Documentation


                The main sections of a class document include the
                following:
                – The class hierarchy
                – A description of the class and its general purpose
                – A list of attributes
                – A list of constructors
                – A list of methods
                – A detailed list of attributes with descriptions
                – A detailed list of constructors with descriptions and formal
                  parameter lists
                – A detailed list of methods with descriptions and formal
                  parameter lists




     Ver. 1.0                        Session 1                             Slide 28 of 31
Java Programming Language
Summary


               In this session, you learned that:
                  The key features of Java technology include:
                    •   A programming language
                    •   A development environment
                    •   An application environment
                    •   A deployment environment
                  JVM can be defined as an imaginary machine that is
                  implemented by emulating it in software on a real machine.
                  Java source files are compiled, get converted into a bytecode
                  file. At runtime, the bytecodes are loaded, checked, and run in
                  an interpreter.
                  Garbage collector checks for and frees memory no longer
                  needed, automatically.




    Ver. 1.0                          Session 1                          Slide 29 of 31
Java Programming Language
Summary (Contd.)


               The three main tasks performed by the JVM include:
                • Loads code
                • Verifies code
                • Executes code
               There are five primary workflows in a software development
               project: Requirement capture, Analysis, Design,
               Implementation, and Test.
               Abstraction means ignoring the non-essential details of an
               object and concentrating on its essential details.
               Encapsulation provides data representation flexibility by hiding
               the implementation details of a class.
               The Java technology class can be declared by using the
               declaration:
                 <modifier> * class <class name>
               The declaration of a Java object attribute can be done as:
                 <modifier> * <type> <name>
    Ver. 1.0                      Session 1                            Slide 30 of 31
Java Programming Language
Summary (Contd.)


                   The definition of methods can be done as:
                      <modifier> * <return type> <name> (<argument>
                        *)
               –   The dot operator enables you to access non-private attribute
                   and method members of a class.
               –   A constructor is a set of instructions designed to initialize an
                   instance of a class.
               –   The Java technology programming language provides the
                   package statement as a way to group related classes.
               –   The import statement tells the compiler where to find the
                   classes which are grouped in packages.
               –   The Java technology API consists of a set of HTML files. This
                   documentation has a hierarchical layout, where the home page
                   lists all the packages as hyperlinks.



    Ver. 1.0                         Session 1                            Slide 31 of 31
Ad

More Related Content

What's hot (20)

01 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_0101 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_01
Niit Care
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
Niit Care
 
04 iec t1_s1_oo_ps_session_05
04 iec t1_s1_oo_ps_session_0504 iec t1_s1_oo_ps_session_05
04 iec t1_s1_oo_ps_session_05
Niit Care
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 
07 iec t1_s1_oo_ps_session_10
07 iec t1_s1_oo_ps_session_1007 iec t1_s1_oo_ps_session_10
07 iec t1_s1_oo_ps_session_10
Niit Care
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
Niit Care
 
05 iec t1_s1_oo_ps_session_07
05 iec t1_s1_oo_ps_session_0705 iec t1_s1_oo_ps_session_07
05 iec t1_s1_oo_ps_session_07
Niit Care
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
arnold 7490
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Java features
Java featuresJava features
Java features
Prashant Gajendra
 
01 gui 01
01 gui 0101 gui 01
01 gui 01
Niit Care
 
Java swing 1
Java swing 1Java swing 1
Java swing 1
Mukesh Tekwani
 
11 iec t1_s1_oo_ps_session_16
11 iec t1_s1_oo_ps_session_1611 iec t1_s1_oo_ps_session_16
11 iec t1_s1_oo_ps_session_16
Niit Care
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
10 iec t1_s1_oo_ps_session_14
10 iec t1_s1_oo_ps_session_1410 iec t1_s1_oo_ps_session_14
10 iec t1_s1_oo_ps_session_14
Niit Care
 
Programming in Java
Programming in JavaProgramming in Java
Programming in Java
Abhilash Nair
 
Java basic introduction
Java basic introductionJava basic introduction
Java basic introduction
Ideal Eyes Business College
 
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_1712 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17
Niit Care
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
ravikirantummala2000
 
01 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_0101 iec t1_s1_oo_ps_session_01
01 iec t1_s1_oo_ps_session_01
Niit Care
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
Niit Care
 
04 iec t1_s1_oo_ps_session_05
04 iec t1_s1_oo_ps_session_0504 iec t1_s1_oo_ps_session_05
04 iec t1_s1_oo_ps_session_05
Niit Care
 
07 iec t1_s1_oo_ps_session_10
07 iec t1_s1_oo_ps_session_1007 iec t1_s1_oo_ps_session_10
07 iec t1_s1_oo_ps_session_10
Niit Care
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
Niit Care
 
05 iec t1_s1_oo_ps_session_07
05 iec t1_s1_oo_ps_session_0705 iec t1_s1_oo_ps_session_07
05 iec t1_s1_oo_ps_session_07
Niit Care
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
11 iec t1_s1_oo_ps_session_16
11 iec t1_s1_oo_ps_session_1611 iec t1_s1_oo_ps_session_16
11 iec t1_s1_oo_ps_session_16
Niit Care
 
10 iec t1_s1_oo_ps_session_14
10 iec t1_s1_oo_ps_session_1410 iec t1_s1_oo_ps_session_14
10 iec t1_s1_oo_ps_session_14
Niit Care
 
12 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_1712 iec t1_s1_oo_ps_session_17
12 iec t1_s1_oo_ps_session_17
Niit Care
 

Viewers also liked (9)

Intuit commissions manager
Intuit commissions managerIntuit commissions manager
Intuit commissions manager
sshhzap
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
Java Basics
Java BasicsJava Basics
Java Basics
Dhanunjai Bandlamudi
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Chapter 1. java programming language overview
Chapter 1. java programming language overviewChapter 1. java programming language overview
Chapter 1. java programming language overview
Jong Soon Bok
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
Indika Munaweera Kankanamge
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for Java
Aleksander Pohl
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
Jussi Pohjolainen
 
Object-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochObject-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady Booch
Sorina Chirilă
 
Intuit commissions manager
Intuit commissions managerIntuit commissions manager
Intuit commissions manager
sshhzap
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
sshhzap
 
Chapter 1. java programming language overview
Chapter 1. java programming language overviewChapter 1. java programming language overview
Chapter 1. java programming language overview
Jong Soon Bok
 
Jena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for JavaJena – A Semantic Web Framework for Java
Jena – A Semantic Web Framework for Java
Aleksander Pohl
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
Jussi Pohjolainen
 
Object-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady BoochObject-Oriented Analysis And Design With Applications Grady Booch
Object-Oriented Analysis And Design With Applications Grady Booch
Sorina Chirilă
 
Ad

Similar to Java session01 (20)

What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
 
Niit Care
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
DeepanshuMidha5140
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Hamid Ghorbani
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVAObject Oriented Programming-JAVA
Object Oriented Programming-JAVA
Home
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
Java solution
Java solutionJava solution
Java solution
1Arun_Pandey
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
EduclentMegasoftel
 
Java Tutorial 1
Java Tutorial 1Java Tutorial 1
Java Tutorial 1
Tushar Desarda
 
Java1
Java1Java1
Java1
computertuitions
 
Java
Java Java
Java
computertuitions
 
brief introduction to core java programming.pptx
brief introduction to core java programming.pptxbrief introduction to core java programming.pptx
brief introduction to core java programming.pptx
ansariparveen06
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
02-Java Technology Details.ppt
02-Java Technology Details.ppt02-Java Technology Details.ppt
02-Java Technology Details.ppt
JyothiAmpally
 
Java2020 programming basics and fundamentals
Java2020 programming basics and fundamentalsJava2020 programming basics and fundamentals
Java2020 programming basics and fundamentals
swecsaleem
 
Object Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for studentsObject Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for students
ASHASITTeaching
 
Iintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptxIintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptx
MayankParashar31
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Debasish Pratihari
 
Javamschn3
Javamschn3Javamschn3
Javamschn3
Sudipto Chattopadhyay
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
Shaharyar khan
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
Hamid Ghorbani
 
Object Oriented Programming-JAVA
Object Oriented Programming-JAVAObject Oriented Programming-JAVA
Object Oriented Programming-JAVA
Home
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
brief introduction to core java programming.pptx
brief introduction to core java programming.pptxbrief introduction to core java programming.pptx
brief introduction to core java programming.pptx
ansariparveen06
 
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Java basic part 2 : Datatypes Keywords Features Components Security Exceptions
Soumen Santra
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
02-Java Technology Details.ppt
02-Java Technology Details.ppt02-Java Technology Details.ppt
02-Java Technology Details.ppt
JyothiAmpally
 
Java2020 programming basics and fundamentals
Java2020 programming basics and fundamentalsJava2020 programming basics and fundamentals
Java2020 programming basics and fundamentals
swecsaleem
 
Object Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for studentsObject Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for students
ASHASITTeaching
 
Iintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptxIintroduction to java , Java Coding , basics of java.pptx
Iintroduction to java , Java Coding , basics of java.pptx
MayankParashar31
 
Ad

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
Niit Care
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
Niit Care
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
Niit Care
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
Niit Care
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
Niit Care
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
Niit Care
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
Niit Care
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
Niit Care
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
Niit Care
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
Niit Care
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
Niit Care
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
Niit Care
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
Niit Care
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
Niit Care
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
Niit Care
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
Niit Care
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
Niit Care
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
Niit Care
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
Niit Care
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
Niit Care
 

Recently uploaded (20)

Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
How to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabberHow to Install & Activate ListGrabber - eGrabber
How to Install & Activate ListGrabber - eGrabber
eGrabber
 
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Ivano Malavolta
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?Shoehorning dependency injection into a FP language, what does it take?
Shoehorning dependency injection into a FP language, what does it take?
Eric Torreborre
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Q1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor PresentationQ1 2025 Dropbox Earnings and Investor Presentation
Q1 2025 Dropbox Earnings and Investor Presentation
Dropbox
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 

Java session01

  • 1. Java Programming Language Objectives • In this session, you will learn to: Describe the key features of Java technology Write, compile, and run a simple Java technology application Describe the function of the Java Virtual Machine Define garbage collection List the three tasks performed by the Java platform that handle code security Define modeling concepts: abstraction, encapsulation, and packages Discuss why you can reuse Java technology application code Define class, member, attribute, method, constructor, and package Use the access modifiers private and public as appropriate for the guidelines of encapsulation Ver. 1.0 Session 1 Slide 1 of 31
  • 2. Java Programming Language Objectives (Contd.) Invoke a method on a particular object Use the Java technology Application Programming Interface online documentation Ver. 1.0 Session 1 Slide 2 of 31
  • 3. Java Programming Language Key Features of Java Technology A programming language A development environment An application environment A deployment environment Java Technology is used for developing both applets and applications. Ver. 1.0 Session 1 Slide 3 of 31
  • 4. Java Programming Language Primary Goals of the Java Technology Provides an easy-to-use language by: Avoiding many pitfalls of other languages Being object-oriented Enables code streamlining Provides an interpreted environment for: Improved speed of development Code portability Loads classes dynamically, i.e., at the time they are actually needed Supports changing programs dynamically during runtime by loading classes from distinct sources Furnishes better security Enable users to run more than one thread of an activity Ver. 1.0 Session 1 Slide 4 of 31
  • 5. Java Programming Language Primary Features of the Java Technology The Java Virtual Machine (JVM™) Garbage collection The Java Runtime Environment (JRE) JVM tool interface Ver. 1.0 Session 1 Slide 5 of 31
  • 6. Java Programming Language The Java Virtual Machine JVM provides definitions for the: Instruction set (Central Processing Unit [CPU]) Register set Class file format Runtime stack Garbage-collected heap Memory area Fatal error reporting mechanism High-precision timing support Ver. 1.0 Session 1 Slide 6 of 31
  • 7. Java Programming Language Garbage Collection Garbage collection has the following characteristics: Checks for and frees memory no longer needed, automatically. Provides a system-level thread to track memory allocation. Ver. 1.0 Session 1 Slide 7 of 31
  • 8. Java Programming Language The Java Runtime Environment • The Java application environment performs as follows: Ver. 1.0 Session 1 Slide 8 of 31
  • 9. Java Programming Language JVM™ Tasks The JVM performs three main tasks: Loads code – Performed by the class loader. Verifies code – Performed by the bytecode verifier. Executes code – Performed by the runtime interpreter. Ver. 1.0 Session 1 Slide 9 of 31
  • 10. Java Programming Language The Class Loader Loads all classes necessary for the execution of a program. Maintains classes of the local file system in separate namespaces. Avoids execution of the program whose bytecode has been changed illegally. Ver. 1.0 Session 1 Slide 10 of 31
  • 11. Java Programming Language The Bytecode Verifier All class files imported across the network pass through the bytecode verifier, which ensures that: The code adheres to the JVM specification. The code does not violate system integrity. The code causes no operand stack overflows or underflows. The parameter types for all operational code are correct. No illegal data conversions (the conversion of integers to pointers) have occurred. Ver. 1.0 Session 1 Slide 11 of 31
  • 12. Java Programming Language Java Technology Runtime Environment Ver. 1.0 Session 1 Slide 12 of 31
  • 13. Java Programming Language A simple Java Application Let see how to create a simple Java Application. Ver. 1.0 Session 1 Slide 13 of 31
  • 14. Java Programming Language The Analysis and Design Phase Analysis describes what the system needs to do: Modeling the real-world, including actors and activities, objects, and behaviors. Design describes how the system does it: Modeling the relationships and interactions between objects and actors in the system. Finding useful abstractions to help simplify the problem or solution. Ver. 1.0 Session 1 Slide 14 of 31
  • 15. Java Programming Language Declaring Java Technology Classes Basic syntax of a Java class: <modifier>* class <class_name> { <attribute_declaration>* <constructor_declaration>* <method_declaration>* } Example: public class MyFirstClass { private int age; public void setAge(int value) { age = value; } } Ver. 1.0 Session 1 Slide 15 of 31
  • 16. Java Programming Language Declaring Attributes Basic syntax of an attribute: <modifier>* <type> <name> [ = <initial_value>]; Example: public class MyFirstClass { private int x; private float y = 10000.0F; private String name = “NIIT"; } Ver. 1.0 Session 1 Slide 16 of 31
  • 17. Java Programming Language Declaring Methods Basic syntax of a method: <modifier>* <return_type> <name> ( <argument>* ){ <statement>* } Example: public class Dog { private int weight; public int getWeight() { return weight; } public void setWeight(int newWeight) { if ( newWeight > 0 ) { weight = newWeight; } } } Ver. 1.0 Session 1 Slide 17 of 31
  • 18. Java Programming Language Accessing Object Members To access object members, including attributes and methods, dot notation is used The dot notation is: <object>.<member> Examples: d.setWeight(42); d.weight = 42; // only permissible if weight is public Ver. 1.0 Session 1 Slide 18 of 31
  • 19. Java Programming Language Class Representation Using UML • Class representation of MyDate class: MyDate Class name -day : int -month : int Attributes -year : int +getDay() +getMonth() +getYear() Methods +setDay(int) : boolean +setMonth(int) : boolean +setYear(int) : boolean Ver. 1.0 Session 1 Slide 19 of 31
  • 20. Java Programming Language Abstraction Abstraction means ignoring the non-essential details of an object and concentrating on its essential details. Ver. 1.0 Session 1 Slide 20 of 31
  • 21. Java Programming Language Encapsulation Encapsulation provides data representation flexibility by: Hiding the implementation details of a class. Forcing the user to use an interface to access data. Making the code more maintainable. Ver. 1.0 Session 1 Slide 21 of 31
  • 22. Java Programming Language Declaring Constructors • A constructor is a set of instructions designed to initialize an instance. • Basic syntax of a constructor: [<modifier>] <class_name> ( <argument>* ) { <statement>* } Example: public class Dog { private int weight; public Dog() { weight = 42; } } Ver. 1.0 Session 1 Slide 22 of 31
  • 23. Java Programming Language The Default Constructor There is always at least one constructor in every class. If the programmer does not supply any constructor, the default constructor is present automatically. The characteristics of default constructor: – The default constructor takes no arguments. – The default constructor body is empty. – The default constructor enables you to create object instances with new xyz() without having to write a constructor. Ver. 1.0 Session 1 Slide 23 of 31
  • 24. Java Programming Language Source File Layout Basic syntax of a Java source file: [<package_declaration>] <import_declaration>* <class_declaration>+ For example, the VehicleCapacityReport.java file can be written as: package shipping.reports; import shipping.domain.*; import java.util.List; import java.io.*; public class VehicleCapacityReport { private List vehicles; public void generateReport(Writer output) {...} } Ver. 1.0 Session 1 Slide 24 of 31
  • 25. Java Programming Language Software Packages • Packages help manage large software systems. • Packages can contain classes and sub-packages. Ver. 1.0 Session 1 Slide 25 of 31
  • 26. Java Programming Language Software Packages (Contd.) Basic syntax of the import statement: import <pkg_name>[.<sub_pkg_name>]*.<class_name>; or import <pkg_name>[.<sub_pkg_name>]*.*; Examples: import java.util.List; import java.io.*; import shipping.gui.reportscreens.*; The import statement does the following: Precedes all class declarations Tells the compiler where to find classes Ver. 1.0 Session 1 Slide 26 of 31
  • 27. Java Programming Language Deployment In order to deploy an application without manipulating the user’s CLASSPATH environment variable, create an executable Java Archive (JAR) File. To deploy library code in a JAR file, copy the JAR file into the ext subdirectory of the lib directory in the main directory of the JRE. Ver. 1.0 Session 1 Slide 27 of 31
  • 28. Java Programming Language Using the Java Technology API Documentation The main sections of a class document include the following: – The class hierarchy – A description of the class and its general purpose – A list of attributes – A list of constructors – A list of methods – A detailed list of attributes with descriptions – A detailed list of constructors with descriptions and formal parameter lists – A detailed list of methods with descriptions and formal parameter lists Ver. 1.0 Session 1 Slide 28 of 31
  • 29. Java Programming Language Summary In this session, you learned that: The key features of Java technology include: • A programming language • A development environment • An application environment • A deployment environment JVM can be defined as an imaginary machine that is implemented by emulating it in software on a real machine. Java source files are compiled, get converted into a bytecode file. At runtime, the bytecodes are loaded, checked, and run in an interpreter. Garbage collector checks for and frees memory no longer needed, automatically. Ver. 1.0 Session 1 Slide 29 of 31
  • 30. Java Programming Language Summary (Contd.) The three main tasks performed by the JVM include: • Loads code • Verifies code • Executes code There are five primary workflows in a software development project: Requirement capture, Analysis, Design, Implementation, and Test. Abstraction means ignoring the non-essential details of an object and concentrating on its essential details. Encapsulation provides data representation flexibility by hiding the implementation details of a class. The Java technology class can be declared by using the declaration: <modifier> * class <class name> The declaration of a Java object attribute can be done as: <modifier> * <type> <name> Ver. 1.0 Session 1 Slide 30 of 31
  • 31. Java Programming Language Summary (Contd.) The definition of methods can be done as: <modifier> * <return type> <name> (<argument> *) – The dot operator enables you to access non-private attribute and method members of a class. – A constructor is a set of instructions designed to initialize an instance of a class. – The Java technology programming language provides the package statement as a way to group related classes. – The import statement tells the compiler where to find the classes which are grouped in packages. – The Java technology API consists of a set of HTML files. This documentation has a hierarchical layout, where the home page lists all the packages as hyperlinks. Ver. 1.0 Session 1 Slide 31 of 31
  翻译: