Basic Java
Primitive types:
Primitive types are the most basic data types available within the Java language. There are 8: boolean , byte , char , short , int , long , float and double . These types serve as the building blocks of data manipulation in Java.
Class & Object:
Object - Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.
Class - A class can be defined as a template/blue print that describes the behaviors/states that object of its type support.
Class contains following variable types:
Local variables:
- Inside the method, constructors or block.
- Be declared and initialized within the method and the variable will be destroyed when the method has completed.
Instance variables:
- Within a class but outside of any method.
- Initialized when the class is instantiated.
- Can be accessed from inside any method, constructors or blocks of that particular class.
Class variables:
- declared with in a class
- outside any method
- with the static keyword.