0% found this document useful (0 votes)
17 views

08.variable and DataTypes in Java

Uploaded by

shoth456
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

08.variable and DataTypes in Java

Uploaded by

shoth456
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

08. Variable & datatypes in Java By Mr.

Vishnu

Variable and DataTypes in Java

Variable:

Variable is the name of reserved memory location. It means when we declare a variable
some part of memory is reserved.

e.g. int var1 = 35;

var1 is a variable here.

Variable Types:

Local variable:

A variable that is declared within the method, constructor, or block is known as local
variable.

No Access modifier is used for local variables. Scope of local variable is limited to that
method, constructor, or block only in which it declared.

Instance variable:

1
Sri Sureka Technologies, NearAndraBank,Opposite Geethanjali High School, Near S.R.Nagar
UmeshChandraStachu, S.R.Nagar, Hyderabad-500038, Ph: 040-66616677, Mobile: +91-9885602332.
08. Variable & datatypes in Java By Mr. Vishnu

A variable that is declared within the class but outside of method, constructor, or block
is known as instance variable (Non static). They are associated with object. Access
modifiers can be used with instance variables. Inside class you can access instance
variable direct by variable name without any object reference.
Static variable:

A variable that is declared within the class with static keyword but outside of method,
constructor, or block is known as Static/class variable. They are associated with class.
Static variable are accessed by ClassName.VariableName.

Data types:

As we discussed when a variable is declared some part of memory is reserved. But how
much memory will be reserved. It depends upon the data type of the variable. i.e. how
much memory will be reserved and which type of data can be stored in reserved
memory is depends upon data type of the variable.

Data types in java:

1. Primitive data types:

Primitive data types are predefined in the language.

2
Sri Sureka Technologies, NearAndraBank,Opposite Geethanjali High School, Near S.R.Nagar
UmeshChandraStachu, S.R.Nagar, Hyderabad-500038, Ph: 040-66616677, Mobile: +91-9885602332.
08. Variable & datatypes in Java By Mr. Vishnu

3
Sri Sureka Technologies, NearAndraBank,Opposite Geethanjali High School, Near S.R.Nagar
UmeshChandraStachu, S.R.Nagar, Hyderabad-500038, Ph: 040-66616677, Mobile: +91-9885602332.

You might also like