Basics of Java variables, methods , class & object

 Variable -:  A piece of memory that can contain a data value.

Variable Types -:

  • Local Variable -: variable that define & initialized inside a method (variable will be destroyed when the method has completed)
    • Instance Variable (Global Variable) -: variable within a class but outside any method.                         (Initialized when the class is instantiated, can be accessed from inside any method, constructor or block of that particular class) 
    • Class Variable -: Variable declared within a class, outside any method with the static key word.

    Attribute = Property =Global Variable

    "Global variable can define with access modifier. But local variable not allow to define with access modifier"

    Object -: A unit that store variables & methods (to create a software)

    Object have states & behaviors
    ex-: Dog has,
    state -: color, name
    behavior -: barking, eating


    Class -: Class can be define as a template/blueprint that describes the behavior/state of the object.


    Method -: Change state of the object




    Comments

    Popular posts from this blog

    Create your first Java program

    Java Variables

    Java OOP