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
Comments
Post a Comment