Assignment of AOOP
Assignment of AOOP
- Instance variable: an instance variable is declared within a class but outside of any
method, it belongs to the instance (object) of the class and can be accessed throughout
the class.
Instance variable: an instance variable is declared within a class but outside of any
method, it belongs to the instance (object) of the class and can be accessed throughout
the class.
Example of Instance variable:
Example:
5. Declaring a static variable: // we declare a static variable with the `static` keyword
typically within a class
6. Scope of a local variable: // the scope of a local variable is limited to the method or
block in which it is declared.
A local variable can`t be accessed outside their scope so there`s no direct way to access
them outside the method or block where they are declared.
System.out.println(b);