01 java.pptx

Upload: sab

Post on 01-Mar-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/25/2019 01 JAVA.pptx

    1/104

    JAVAProgramming

    Sri Krishna I-Tech andManagement Solutions Pvt Ltd

  • 7/25/2019 01 JAVA.pptx

    2/104

    TIOBE Index for May 2015

  • 7/25/2019 01 JAVA.pptx

    3/104

  • 7/25/2019 01 JAVA.pptx

    4/104

    Java Certification

  • 7/25/2019 01 JAVA.pptx

    5/104

    Java Certification

  • 7/25/2019 01 JAVA.pptx

    6/104

  • 7/25/2019 01 JAVA.pptx

    7/104

    OCP Java S! Certification Code

    1Z0-851

  • 7/25/2019 01 JAVA.pptx

    8/104

    Java Contents

  • 7/25/2019 01 JAVA.pptx

    9/104

    Java Course Modules

    "#$undamentals of the %ava Programming Language& Java S

    !

    '#Java Programming Language& Java S !

    (#)e* Com+onent ,evelo+ment ith Servlets . JSPs& Java

    !

    /#,evelo+ing A++lication for the Java ! Platform

  • 7/25/2019 01 JAVA.pptx

    10/104

    JAVA

    1. Fundamentals of the java Programming

    Language, Java SE 6

    2. Java Programming Language, Java SE 6

  • 7/25/2019 01 JAVA.pptx

    11/104

    JAVA Certifications

    1. Fundamentals of the java Programming Language, Java SE 6

    2. Java Programming Language, Java SE 6

    OCA Java SE 6 ro!ra""er

    OC Java SE 6 ro!ra""er

  • 7/25/2019 01 JAVA.pptx

    12/104

    Fundamentals of the java Programming

    Language, Java SE 6

    "# 0+laining %ava technolog1#

    '# Anal12ing a +ro*lem and designing a solution#

    (# ,evelo+ing and testing the %ava technolog1

    +rogram#

    /# ,eclaring& initiali2ing& and using varia*les#

    3# Creating and using o*%ects#

    !# 4sing o+erations and decision constructs#

    5# 4sing loo+ constructs#

    6# ,evelo+ing and using methods#

    7# Im+lementing enca+sulations and constructors#

    "8# Creating and using arra1s#

    ""# Im+lementing inheritance#

  • 7/25/2019 01 JAVA.pptx

    13/104

    Java Programming Language, Java SE 6

    "# O*%ects-oriented +rogramming#

    '# Identifiers& 9e1ords& and t1+es#

    (# 0+ressions and flo control#

    /# Arra1s& class design& advanced class features#

    3# 0ce+tions and assertions#

    !# Collections and generics frameor9#

    5# I:O fundamentals& console I:O and file I:O#

    6# ;uilding %ava

  • 7/25/2019 01 JAVA.pptx

    14/104

    Java Contents Java +rogramming *asics#

    Value t1+e and ?eference t1+e#

    Methods and its related conce+ts#

    Constructor and its related conce+ts#

    Inheritance and its t1+es#

    A*stract class and Interface conce+ts#

    Inner classes#

    0ce+tion =andling#

    Multithreading#

    )ra++er classes and String o+erations#

    Collections $rameor9#

  • 7/25/2019 01 JAVA.pptx

    15/104

    Console A:P @e#g# Sho+ *illing

    )indos A:P @e#g# MS-ord& 0cel )e* A:P @e#g#

  • 7/25/2019 01 JAVA.pptx

    16/104

    ro!ra""#n! Bas#$s

  • 7/25/2019 01 JAVA.pptx

    17/104

    int a "88D

    char * ESFD

    float c '8#/fD

    int G0 .aD

    char G1 .*Dfloat G2 .cD

    Pointers

    ?eferenceT1+e

    Value T1+e

  • 7/25/2019 01 JAVA.pptx

    18/104

    Class

    O*%ect

    O*%ect Oriented Programming

  • 7/25/2019 01 JAVA.pptx

    19/104

  • 7/25/2019 01 JAVA.pptx

    20/104

    Source code

    (.java)

    %atfor" Inde&enden$e

    Byte code

    (.class)

    JDK

    JVM

    Class load

    Object creation

    J'E

  • 7/25/2019 01 JAVA.pptx

    21/104

    Class and O*%ects

    Object

    Object

    Object

    C(ASS

    B%)e &r#nt

    *o)se

    *o)se

    *o)se

  • 7/25/2019 01 JAVA.pptx

    22/104

    C%ass

    class Student

    H

    int idD void dis+la1@

    H

    contidD

    ;lue Print

    Student@H

  • 7/25/2019 01 JAVA.pptx

    23/104

    C%ass

    class Student

    H

    int idD Student@

    H

    Invo9ing Constructor

    Creating O*%ect

    Student

    o*1

    2

  • 7/25/2019 01 JAVA.pptx

    24/104

    int G0D

    Student Go*D

    Pointers

    Reference Type

    Reference Type

  • 7/25/2019 01 JAVA.pptx

    25/104

    Student o*D

    O*%ect Creation

    O*%ect creation

    ne Student@

    O*%ect creation

  • 7/25/2019 01 JAVA.pptx

    26/104

    Student o*D

    Student G+tr ne Student@D

    Pointers

    ?eference T1+e

    Value T1+e

  • 7/25/2019 01 JAVA.pptx

    27/104

    Student

    Go*"D

    C

    Studento*'D C O*%ect

    Creation

    C?eferenceCreation

  • 7/25/2019 01 JAVA.pptx

    28/104

    Student

    Go*"D

    JAVA

    Student

    o*'DJava?eferenceCreation

    C O*%ectCreation

    C?eferenceCreation

  • 7/25/2019 01 JAVA.pptx

    29/104

    Student o*D

    C

    O*%ect creation

    ne Student@

    O*%ect creation

  • 7/25/2019 01 JAVA.pptx

    30/104

    Student o*D

    Java

    ?eference

    ne Student@

    O*%ectcreation

  • 7/25/2019 01 JAVA.pptx

    31/104

    Student o* = ne Student@;

    ?eference

    O*%ect

  • 7/25/2019 01 JAVA.pptx

    32/104

    Student o* ne

    Student@D

    O*%ect Creation in Java

  • 7/25/2019 01 JAVA.pptx

    33/104

    O+,e$t

    class Student

    H

    int idD Student@

    H

    Student o* ne Student@D

    Instance (or) Object

    Student ob = new Student();

    ob.id=200;

    ob.display();

  • 7/25/2019 01 JAVA.pptx

    34/104

    C%ass

    class Student

    H

    int idD void dis+la1@

    H

    coutidD

    Varia*les andMethods

  • 7/25/2019 01 JAVA.pptx

    35/104

    Instance varia*le and Instance methods @non-static#

    Class varia*le and Class methods @static#

    Local varia*le#

    Ty&es of ar#a+%es and Met.ods

  • 7/25/2019 01 JAVA.pptx

    36/104

    class ,emo

    H

    static int aD

    int *D

  • 7/25/2019 01 JAVA.pptx

    37/104

    Source code

    (.java)

    %atfor" Inde&enden$e

    Byte code

    (.class)

    JDK

    JVM

    Class load

    Object creation

    J'E

  • 7/25/2019 01 JAVA.pptx

    38/104

    class ,emo

    H

    static int aD

    int *D

    /e"oa 5000

    ,emo o*%ne,emo@D

    o*%#*"888D

  • 7/25/2019 01 JAVA.pptx

    39/104

    class ,emo

    H

    int aD

    void sum@

    H

    coutaD

    Instan$e var#a+%e and "et.od

    ,emo o"ne ,emo@D

    o"#a"888D

    o"#sum@D

    ,emo o'ne ,emo@D

    o'#a(888D

    o'#sum@D

    o" o'

    a a

    Demo

  • 7/25/2019 01 JAVA.pptx

    40/104

    class ,emo

    H

    static int aD

    static void sum@

    H

    coutaD

    Class varia*le and method

    /e"oa 5000

    /e"os)"34

  • 7/25/2019 01 JAVA.pptx

    41/104

    java.lang.*;

    Java a$a!es

    Object

    System

  • 7/25/2019 01 JAVA.pptx

    42/104

    S1stem#out#+rintln@)elcomeD

    r#nt#n! State"ent

  • 7/25/2019 01 JAVA.pptx

    43/104

    class System

    {

    static int x;static int y;

    }

    Syste" C%ass

    System.x=100; System.y=100;

  • 7/25/2019 01 JAVA.pptx

    44/104

    PrintStream out=new PrintStream();

    Syste" C%ass

    O+,e$t of r#ntStrea" $%ass

  • 7/25/2019 01 JAVA.pptx

    45/104

    class System

    { static PrintStream out=newPrintStream();

    }

    Syste" C%ass

  • 7/25/2019 01 JAVA.pptx

    46/104

    class PrintStream

    {

    void println(int); void println(String);

    }

    r#ntStrea" C%ass

  • 7/25/2019 01 JAVA.pptx

    47/104

    S1stem#out

    A&&%#$at#on

    C%ass ar#a+%e 3stat#$4

    O+,e$t of r#ntStrea"C%ass

  • 7/25/2019 01 JAVA.pptx

    48/104

    S1stem#out#+rintln@)elcomeD

    A&&%#$at#on

    C%ass ar#a+%e 3stat#$4

    O+,e$t of r#ntStrea"C%ass

    Met.od

  • 7/25/2019 01 JAVA.pptx

    49/104

    class Demo

    {

    }

    A&&%#$at#on

  • 7/25/2019 01 JAVA.pptx

    50/104

    class Demo extends !ject

    {

    }

    ,efault *ase class

  • 7/25/2019 01 JAVA.pptx

    51/104

    import java.lang.*;

    class Demo extends !ject

    {Demo()

    {

    }

    }

  • 7/25/2019 01 JAVA.pptx

    52/104

    O*%ect Creation

    class "{

    }class # extends"

    {

    }

    "

    ne A@D

    " #

    ne ;@D

  • 7/25/2019 01 JAVA.pptx

    53/104

    ?eference

    class "{

    }class # extends"

    {

    }

    A o*"D

    ; o*'D

  • 7/25/2019 01 JAVA.pptx

    54/104

    ?eference

    class "{

    }class # extends"

    {

    }

    "

    A o*"D

    " #

    ; o*'D

  • 7/25/2019 01 JAVA.pptx

    55/104

    Inheritance

    class "{

    }class # extends"

    {

    }

    " " #A o" ne ;@D

    " # "#; o' ne ;@D

  • 7/25/2019 01 JAVA.pptx

    56/104

    Inheritance

    class AHclass ; e0tends A

    H

    A s" ne ;@D

    ; s' @;s"D

  • 7/25/2019 01 JAVA.pptx

    57/104

    Inheritance

    A s" ne ;@D

    ; s' @;s"D

    &-$ast#n!

    /o7n$ast#n!-$ast#n!

  • 7/25/2019 01 JAVA.pptx

    58/104

    " class $eferencemay containsame%class !ject

    or su*%class !ject

    A r" ne A@D

    A r' ne ;@D

    " class O*%ectmay !e &ndersame%class re'erence or *ase%class

    re'erence

    A r" ne ;@D

    ; r' ne ;@D

    A r" ne ;@D

  • 7/25/2019 01 JAVA.pptx

    59/104

    A r" neA@D

    A r' ne;@D

    A r" ne ;@D

    ; r' ne ;@D

    B $%ass O+,e$t#s stored )nder t.e 'eferen$eof $%ass B

    B $%ass O+,e$t#s stored )nder t.e 'eferen$eof $%ass A

    A$%ass 'eferen$e#s .o%d#n! O+,e$tof $%ass A

    A$%ass 'eferen$e#s .o%d#n! O+,e$tof $%ass A

  • 7/25/2019 01 JAVA.pptx

    60/104

  • 7/25/2019 01 JAVA.pptx

    61/104

    Inheritance

    class AH

    class ;Hclass CH

    ne A@D

    ne ;@D

    ne C@D

    O A

    O B

    O C

  • 7/25/2019 01 JAVA.pptx

    62/104

    Inheritance

    class AH

    class ;Hclass CH

    O*%ect o"neA@D

    O*%ect o'ne;@D

    O* ect o(ne

    O A

    O B

    O C

  • 7/25/2019 01 JAVA.pptx

    63/104

    Inheritance

    class AH

    class ;Hclass CH

    O*%ect s" neA@D

    A s' @As"D

    O A

  • 7/25/2019 01 JAVA.pptx

    64/104

    Inheritance

    class AH

    O*%ect s" neA@D

    A s' @As"D

    &-$ast#n!

    /o7n$ast#n!-$ast#n!

  • 7/25/2019 01 JAVA.pptx

    65/104

    Methods overloading

    If a class have multiple methods by same name

    but diffeent paametes! it is "no#n as

    Met.od Over%oad#n!$

    In$reases t.e reada+#%#ty of t.e &ro!ra"$

  • 7/25/2019 01 JAVA.pptx

    66/104

    Methods overloading

    %hee ae t#o #ays to oveload the method in java

    &$By chan'in' numbe of a'uments

    ($By chan'in' the data type

  • 7/25/2019 01 JAVA.pptx

    67/104

    class ,emoH

    void add@

    H

    void add@int 0

    H

    void add@int 0&int 1

    H

    Methods overloading

  • 7/25/2019 01 JAVA.pptx

    68/104

    class ,emoH int 0D void add@ H

    S1stem#out#+rintln@=aiD void add@int 1 H this#01D S1stem#out#+rintln@N 0D

    Methods overloading

    Demo o1=newDemo();

    o1.add();

    o1.add(5);

  • 7/25/2019 01 JAVA.pptx

    69/104

    void calculation@D

    void calculation@H int a'88D

    int */88D S1stem#out#+rintln@a*D

    Methods

  • 7/25/2019 01 JAVA.pptx

    70/104

    void calculation@D

    void calculation@H int a'88D

    int */88D S#o#+@a*D

    Methods

    Method ,eclaration

    Method ,efinition

    Method ,eclaration

  • 7/25/2019 01 JAVA.pptx

    71/104

    void calculation@D

    void calculation@H int a'88D

    int */88D S1stem#out#+rintln@a*D

    Methods

    A*stract Method

    Concrete Method

  • 7/25/2019 01 JAVA.pptx

    72/104

    class AH void add@ H S1stem#out#+rintln@=aiD class ; e0tends AH

    Method Overriding

  • 7/25/2019 01 JAVA.pptx

    73/104

    class AH

    void add@

    H

    S1stem#out#+rintln@=aiD

    class ; e0tends AH

    void add@

    H S1stem#out#+rintln@)elcomeD

    Method Overriding

  • 7/25/2019 01 JAVA.pptx

    74/104

    class AH void add@Dclass ; e0tends AH

    Method Overriding

  • 7/25/2019 01 JAVA.pptx

    75/104

    class AH void add@Dclass ; e0tends A

    Hvoid add@

    H

    S1stem#out#+rintln@)elcomeD

    Method Overriding

  • 7/25/2019 01 JAVA.pptx

    76/104

    class AH

    int 0D

    A@

    H

    A@int 1

    H

    this#01D

    Constructor

    ! o1=new !();

    ! o"=new !(#);

  • 7/25/2019 01 JAVA.pptx

    77/104

    Single

    &ltilevel

    ierarcal

    &ltiple

    y!rid

    Inheritance

  • 7/25/2019 01 JAVA.pptx

    78/104

    Inheritance

    A

    B

    A

    B

    A B

    C

    C

    A

    B C

    Multi+le Inheritance

  • 7/25/2019 01 JAVA.pptx

    79/104

    Multi+le Inheritance

    !

    C

    B

    add)*+ add)*+

    add)*

    ,

    -

  • 7/25/2019 01 JAVA.pptx

    80/104

    void calculation@D

    void calculation@H int a'88D

    int */88D S1stem#out#+rintln@a*D

    Methods

    h d

  • 7/25/2019 01 JAVA.pptx

    81/104

    a*stract void calculation@D

    Methods

    A* Cl

  • 7/25/2019 01 JAVA.pptx

    82/104

    a!stract class +ar

    {

    a!stract void door(); a!stract void glass();

    }

    A*stract Class

    A* Cl

  • 7/25/2019 01 JAVA.pptx

    83/104

    a!stract class +ar{

    a!stract void door();

    a!stract void glass();

    void weel()

    {

    System.o&t.println(,-eel);

    }}

    A*stract Class

    A* t t Cl

  • 7/25/2019 01 JAVA.pptx

    84/104

    A*stract Class

    ;en2 Audi ;M)

    CA?

    A* t t Cl

  • 7/25/2019 01 JAVA.pptx

    85/104

    A*stract Class

    ;en2 Audi ;M)

    CA? void door@Dvoidglass@D

    A* t t Cl

  • 7/25/2019 01 JAVA.pptx

    86/104

    A*stract Class

    ;en2 Audi ;M)

    CA? void door@Dvoidglass@D

    void door@D

    void glass@D

    void door@D

    void glass@D

    void door@D

    void glass@D

    A* t t Cl

  • 7/25/2019 01 JAVA.pptx

    87/104

    class Lancer e0tends CarH

    void door@

    H

    S1stem#out#+rintln@Lancer doorD

    void glass@

    H

    S1stem#out#+rintln@Lancer glassD

    A*stract Class

    A* t t Cl I t f

  • 7/25/2019 01 JAVA.pptx

    88/104

    A*stract Class

    +ontains a!stract

    and concrete metods.

    A*stract Class vs Interface

    Interface

    +ontains only

    a!stract metods.

    I t f

  • 7/25/2019 01 JAVA.pptx

    89/104

    Interface

    ;en2 Audi ;M)

    CA? void door@Dvoidglass@D

    void door@D

    void glass@D

    void door@D

    void glass@D

    void door@D

    void glass@D

  • 7/25/2019 01 JAVA.pptx

    90/104

    I t f

  • 7/25/2019 01 JAVA.pptx

    91/104

    inter'ace +ar{

    p&!lic a!stract void door();

    p&!lic a!stract void glass();}

    Interface

    ,efault

    Interface

  • 7/25/2019 01 JAVA.pptx

    92/104

    class Lancer im+lements CarH

    +u*lic void door@

    H

    S1stem#out#+rintln@Lancer doorD

    +u*lic void glass@

    H

    S1stem#out#+rintln@Lancer glassD

    Interface

    Multi+le Inheritance

  • 7/25/2019 01 JAVA.pptx

    93/104

    Multi+le Inheritance

    !

    C

    B

    add)*+ add)*+

    add)*

    ,

    -

    O*%ect Creation

  • 7/25/2019 01 JAVA.pptx

    94/104

    O*%ect Creation

    inter'ace Mail{

    void register();

    void

    validation();

    }

    a!stract class Car{

    void door();

    void glass();

    }

    ne7 Ma#%34

    ne7 Car34

    O*%ect Creation

  • 7/25/2019 01 JAVA.pptx

    95/104

    O*%ect Creation

    inter'ace Mail{

    void register();

    void

    validation();

    }

    a!stract class Car{

    void door();

    void glass();

    }

    ne7 a.oo34

    ne7 Ben934

    O*%ect Creation

  • 7/25/2019 01 JAVA.pptx

    96/104

    O*%ect Creation

    Ma#% o+1 ne7 Ma#%34

    Car $1 ne7 Car34

    O*%ect Creation

  • 7/25/2019 01 JAVA.pptx

    97/104

    O*%ect Creation

    Ma#% o+1 ne7 a.oo34

    Car $1 ne7 Ben934

    Inner Classes

  • 7/25/2019 01 JAVA.pptx

    98/104

    Inner Classes

    class AH

    Inner Classes

  • 7/25/2019 01 JAVA.pptx

    99/104

    Inner Classes

    class AH

    class ;H

    Inner Classes

  • 7/25/2019 01 JAVA.pptx

    100/104

    Inner Classes

    "# >on-Static inner class

    '# Static inner class

    (# Anon1mous inner class

    /# Method Local inner class

    >on-Static

  • 7/25/2019 01 JAVA.pptx

    101/104

    >on-Static

    class AH

    class ;H

    Static

  • 7/25/2019 01 JAVA.pptx

    102/104

    Static

    class AH

    staticclass ;H

    Annon1mous Inner Class

  • 7/25/2019 01 JAVA.pptx

    103/104

    Annon1mous Inner Class

    class AH

    H

    Method Local Inner Class

  • 7/25/2019 01 JAVA.pptx

    104/104

    class AH

    void test@

    Hclass TestH