SlideShare a Scribd company logo
2
Most read
4
Most read
7
Most read
TODAY MY
PRESENTATION TOPIC IS
TYPES OF VARIABLES
Variable
• A variable provides us wit h named st orage t
hat our programs can manipulate.
There are three kinds of variables in
java
• Local variables
• Instance variables
• Class/static variables
Local variables
• Local variables are declared in methods,
constructors, or blocks.
• Local variables are created when the
method, constructor or block is entered
and the variable
• will be destroyed once it exits the
method, constructor or block.
• Access modifiers cannot be used for local
variables.
• Local variables are visible only within the
declared method, constructor or block.
• Local variables are implemented at stack
level internally.
• There is no default value for local
variables so local variables should be
declared and an initial
• value should be assigned before the first
use.
Example
Instance variables
• Instance variables are declared in a class, but
outside a method, constructor or any block.
• Instance variables hold values that must be
referenced by more than one method, constructor
or block, or essential parts of an object's state that
must be present throughout the class.
• Instance variables can be declared in class level
before or after use.
• Access modifiers can be given for instance
variables.
• The instance variables are visible for all
methods, constructors and block in the class.
• Normally, it is recommended to make these
variables private accesslevel. However
visibility for subclasses can be given for these
variables with the use of access modifiers.
• Instance variables have default values. For
numbers the default value is 0, for Booleans it
is false and for object references it is null.
Values can be assigned during the declaration
or within the constructor.
Example
THANK YOU

More Related Content

What's hot (20)

PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPTX
Java package
CS_GDRCST
 
PPT
Function overloading(c++)
Ritika Sharma
 
PDF
Generic Programming
Muhammad Alhalaby
 
PPTX
Data types in C language
kashyap399
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPTX
Constructor in java
Madishetty Prathibha
 
PPTX
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
PPTX
Inline Functions and Default arguments
Nikhil Pandit
 
PPT
Introduction To C#
SAMIR BHOGAYTA
 
PPTX
C# Delegates
Raghuveer Guthikonda
 
PPT
Servlets
Sasidhar Kothuru
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPT
Method overriding
Azaz Maverick
 
PPTX
Java Tokens
Madishetty Prathibha
 
PPTX
OOP Introduction with java programming language
Md.Al-imran Roton
 
PPTX
Jdbc ppt
sandeep54552
 
PPTX
Java program structure
Mukund Kumar Bharti
 
PPT
Abstract class in java
Lovely Professional University
 
PPT
Java Arrays
Jussi Pohjolainen
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Java package
CS_GDRCST
 
Function overloading(c++)
Ritika Sharma
 
Generic Programming
Muhammad Alhalaby
 
Data types in C language
kashyap399
 
Exception Handling in Java
lalithambiga kamaraj
 
Constructor in java
Madishetty Prathibha
 
Virtual function in C++ Pure Virtual Function
Kamlesh Makvana
 
Inline Functions and Default arguments
Nikhil Pandit
 
Introduction To C#
SAMIR BHOGAYTA
 
C# Delegates
Raghuveer Guthikonda
 
Classes objects in java
Madishetty Prathibha
 
Method overriding
Azaz Maverick
 
OOP Introduction with java programming language
Md.Al-imran Roton
 
Jdbc ppt
sandeep54552
 
Java program structure
Mukund Kumar Bharti
 
Abstract class in java
Lovely Professional University
 
Java Arrays
Jussi Pohjolainen
 

Similar to Local variables Instance variables Class/static variables (20)

PDF
7. VARIABLEs presentation in java programming. Pdf
simukondasankananji8
 
PPTX
Computer programming 2 Lesson 6
MLG College of Learning, Inc
 
PPT
3 java - variable type
vinay arora
 
PPTX
Variables in java.pptx
gomathikalai
 
PPT
Java-Variables_about_different_Scope.ppt
JyothiAmpally
 
PPTX
OOP using java (Variable in java)
omeed
 
PPTX
Constant a,variables and data types
mithilesh kumar
 
PPTX
Data types ^J variables and arrays in Java.pptx
sksumayasumaya5
 
PDF
Java unit 7
Shipra Swati
 
PPTX
Unit-1 Data Types and Operators.pptx to computers
csangani1
 
PDF
Definition Name of memory location is called a variable.There are.pdf
mohammadirfan136964
 
PDF
java-basics-1.pdf jfjf hjghjgkj df jfjf hjghjgkj df jfjf hjghjgkj df jfjf hjg...
Indu32
 
PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
class as the basis.pptx
Epsiba1
 
PPTX
Module 4_Chapter One - Java Methods.pptx
jhesorleylaid2
 
PPTX
Learning Java 2 - Variables, Data Types and Operators
MinhNguyen1493
 
PPTX
07 java variables
Zeeshan-Shaikh
 
PPTX
javaClasses.pptx
MattMarino13
 
PPTX
Java Tokens in java program . pptx
CmDept
 
PPT
3. Data types and Variables
Nilesh Dalvi
 
7. VARIABLEs presentation in java programming. Pdf
simukondasankananji8
 
Computer programming 2 Lesson 6
MLG College of Learning, Inc
 
3 java - variable type
vinay arora
 
Variables in java.pptx
gomathikalai
 
Java-Variables_about_different_Scope.ppt
JyothiAmpally
 
OOP using java (Variable in java)
omeed
 
Constant a,variables and data types
mithilesh kumar
 
Data types ^J variables and arrays in Java.pptx
sksumayasumaya5
 
Java unit 7
Shipra Swati
 
Unit-1 Data Types and Operators.pptx to computers
csangani1
 
Definition Name of memory location is called a variable.There are.pdf
mohammadirfan136964
 
java-basics-1.pdf jfjf hjghjgkj df jfjf hjghjgkj df jfjf hjghjgkj df jfjf hjg...
Indu32
 
Java data types, variables and jvm
Madishetty Prathibha
 
class as the basis.pptx
Epsiba1
 
Module 4_Chapter One - Java Methods.pptx
jhesorleylaid2
 
Learning Java 2 - Variables, Data Types and Operators
MinhNguyen1493
 
07 java variables
Zeeshan-Shaikh
 
javaClasses.pptx
MattMarino13
 
Java Tokens in java program . pptx
CmDept
 
3. Data types and Variables
Nilesh Dalvi
 
Ad

Recently uploaded (20)

PDF
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
PDF
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
PDF
June 2025 - Top 10 Read Articles in Network Security and Its Applications
IJNSA Journal
 
PPTX
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PDF
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
PDF
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
PDF
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PPTX
Artificial Intelligence jejeiejj3iriejrjifirirjdjeie
VikingsGaming2
 
PPTX
Precooling and Refrigerated storage.pptx
ThongamSunita
 
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PDF
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
PPTX
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
June 2025 - Top 10 Read Articles in Network Security and Its Applications
IJNSA Journal
 
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
Bayesian Learning - Naive Bayes Algorithm
Sharmila Chidaravalli
 
Clustering Algorithms - Kmeans,Min ALgorithm
Sharmila Chidaravalli
 
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Artificial Intelligence jejeiejj3iriejrjifirirjdjeie
VikingsGaming2
 
Precooling and Refrigerated storage.pptx
ThongamSunita
 
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
Ad

Local variables Instance variables Class/static variables

  • 1. TODAY MY PRESENTATION TOPIC IS TYPES OF VARIABLES
  • 2. Variable • A variable provides us wit h named st orage t hat our programs can manipulate.
  • 3. There are three kinds of variables in java • Local variables • Instance variables • Class/static variables
  • 4. Local variables • Local variables are declared in methods, constructors, or blocks. • Local variables are created when the method, constructor or block is entered and the variable • will be destroyed once it exits the method, constructor or block. • Access modifiers cannot be used for local variables.
  • 5. • Local variables are visible only within the declared method, constructor or block. • Local variables are implemented at stack level internally. • There is no default value for local variables so local variables should be declared and an initial • value should be assigned before the first use.
  • 7. Instance variables • Instance variables are declared in a class, but outside a method, constructor or any block. • Instance variables hold values that must be referenced by more than one method, constructor or block, or essential parts of an object's state that must be present throughout the class. • Instance variables can be declared in class level before or after use. • Access modifiers can be given for instance variables.
  • 8. • The instance variables are visible for all methods, constructors and block in the class. • Normally, it is recommended to make these variables private accesslevel. However visibility for subclasses can be given for these variables with the use of access modifiers. • Instance variables have default values. For numbers the default value is 0, for Booleans it is false and for object references it is null. Values can be assigned during the declaration or within the constructor.