Introduction to Variables in Java | Java Tutorial For Beginners #9

Published: 06 June 2021
on channel: Sumit S Videos
84
7

Introduction to Variables in Java | Java Tutorial For Beginners #9


Variables in Java :
-----------------------------
Variables are used to store the values.
Variable is name of reserved area allocated in memory.
Ex: int roll = 40 ;
here, roll is a variable.

There are three types of variables in java :
------------------------------------------------------------------
1) Instance variable
2) Local variable
3) Static/Class variable


1) Instance variable: Variable declared inside the class but outside methods, constructor or block.
It will be created at the time of object creation.
Access modifiers can be used with instance variables.
Initialization is not mandatory. It has default value provided by JVM.
It will be stored in the Heap memory as the part of object.

2) Local variable : Local variable is declared inside a method, constructor or block.
It will be created while executing the method in which it is declared.
Initialization is mandatory. No default value for local variable.
Access modifiers cannot be used for local variables. Only final keyword can
be used.
Local variable are visible only within the method.
Local variable will be stored inside stack memory

3) Static variable : Variable declared with static keyword are called static variables.
Local variable can not be declared as static.
No need of object creation to call a static variable.
It will be created at the time of class loading.
Scope of static variable is same as the scope of class.

Calling of static variable :
---------------------------------------
Directly possible
By using class name possible
By using object reference name


Learn Core Java From Scratch

Don’t Forget To Like, Comment, Share & Subscribe !!
Keep Learning ! 😊


Important Playlist:

🆓 Software Installation For Developer :    • Software Installation for Developer  

🆓 JDBC Complete Tutorial :    • JDBC Tutorial(Java Database Connectivity)  

🆓 Core Java Tutorial :    • Core Java Tutorials For Beginners  


********************************| Thanks |****************************

#variables #corejava #sumitsvideos #sumitsingh

Related Searches :
local, instance and static variables in java
variables in java
types of variable in java
core java tutorial


On this page of the site you can watch the video online Introduction to Variables in Java | Java Tutorial For Beginners #9 with a duration of hours minute second in good quality, which was uploaded by the user Sumit S Videos 06 June 2021, share the link with friends and acquaintances, this video has already been watched 84 times on youtube and it was liked by 7 viewers. Enjoy your viewing!