SlideShare a Scribd company logo
OOP - JAVA
Variables in Java
4/6/2022 1
Department of Computer
PRO โ€“ GRADE 5
Lecturer. OMEED M. M
Table of contents
๏ถ What is Variable?
๏ถ Allocating memory
๏ถ Types of variables
๏ถ Constructor
4/6/2022 2
Variable in Java
Variables used to store in our computerโ€™s memory
Why called it variable?
Because the values inside the variables are changeable.
๏ƒผ Attributes - things that the object stores data in, generally
variables.
๏ƒผ Methods - Functions and Procedures attached to an Object and
allowing the object to perform actions
4/6/2022 3
Allocating memory
In order to store some data in our computer memory we have to
allocate some space so how we can do that? we will go through
allocating memory,
4/6/2022 4
Allocating memory
For this purpose we have to declare variables.
How we can declare variable we are going to using assignment
We can assign a value to a variable by using (Equal =) operator.
Ex.
String ANY_NAME = โ€œANY_NAMEโ€
4/6/2022 5
Variable in Java
โ€ข Re-difine variable
4/6/2022 6
Variable in Java
โ€ข Println
4/6/2022 7
Types of variables
There are Three type of variables:-
1. Instance variables
2. Local variables
3. Class variables (Static variables)
4/6/2022 8
Instance variables
Instance variables Declared inside class but not inside method.
Ex.
Class test{
Int data=15; //instance variable
Float pi=3.114f; //instance variable
}
Cannot be reinitialized directly within class
Ex.
Class test{
Int data=15; //instance variable
data =20; //Error for correction we have to put it into a method
void testMethod(){
data=20 // correct;
} }
4/6/2022 9
Local variables
Local variables โ€“ Declared inside method or method parameters.
Ex.
Int areatest (int radius){
Int total = radius * radius;
Return total;
}
-These are not accessible outside method.
-They did not get default values.
4/6/2022 10
Class / Static variables
Class variables โˆ’ are variables declared within a class, outside any
method, with the static keyword
-Static variable is shared between all objects because it belong to
the class. It does not belong to the object
-A static variable can be accessed without creating an instance of the
class.
4/6/2022 11
Constructor
A constructor in Java is similar to a method that is invoked when an
object of the class is created.
Unlike Java methods, a constructor has the same name as that of the
class and does not have any return type. For example,
class Test {
Test() {
// constructor body
}
}
4/6/2022 12
Types of variables
class A{
int date=50; //_________ variable
static int m=100; //_________ variable
void method(){
int n=90; //________ variable
}
} //end of class
4/6/2022 13
Any Questions ?
4/6/2022 14

More Related Content

Similar to OOP using java (Variable in java)

packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
madhavi patil
ย 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
SakkaravarthiS1
ย 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
ย 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
Elizabeth alexander
ย 
CHAPTER 3 part1.pdf
CHAPTER 3 part1.pdfCHAPTER 3 part1.pdf
CHAPTER 3 part1.pdf
FacultyAnupamaAlagan
ย 
BIT211_3.pdf
BIT211_3.pdfBIT211_3.pdf
BIT211_3.pdf
Sameer607695
ย 
Java unit 7
Java unit 7Java unit 7
Java unit 7
Shipra Swati
ย 
Classes, objects, methods, constructors, this keyword in java
Classes, objects, methods, constructors, this keyword  in javaClasses, objects, methods, constructors, this keyword  in java
Classes, objects, methods, constructors, this keyword in java
TharuniDiddekunta
ย 
Core Java Introduction | Basics
Core Java Introduction  | BasicsCore Java Introduction  | Basics
Core Java Introduction | Basics
Hรนng Nguyแป…n Huy
ย 
Java defining classes
Java defining classes Java defining classes
Java defining classes
Mehdi Ali Soltani
ย 
Unit 2 Part 1 Constructors.pdf
Unit 2 Part 1 Constructors.pdfUnit 2 Part 1 Constructors.pdf
Unit 2 Part 1 Constructors.pdf
Arpana Awasthi
ย 
Java chapter 4
Java chapter 4Java chapter 4
Java chapter 4
Abdii Rashid
ย 
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
Indu65
ย 
Ppt chapter05
Ppt chapter05Ppt chapter05
Ppt chapter05
Richard Styner
ย 
Delphi qa
Delphi qaDelphi qa
Delphi qa
sandy14234
ย 
Reflection
ReflectionReflection
Reflection
Piyush Mittal
ย 
Unit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxUnit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptx
DrYogeshDeshmukh1
ย 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Sagar Verma
ย 
Introduction to Classes and Objects in Java - Edufect
Introduction to Classes and Objects in Java - EdufectIntroduction to Classes and Objects in Java - Edufect
Introduction to Classes and Objects in Java - Edufect
Edufect
ย 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
Epsiba1
ย 

Similar to OOP using java (Variable in java) (20)

packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
ย 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
ย 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
ย 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
ย 
CHAPTER 3 part1.pdf
CHAPTER 3 part1.pdfCHAPTER 3 part1.pdf
CHAPTER 3 part1.pdf
ย 
BIT211_3.pdf
BIT211_3.pdfBIT211_3.pdf
BIT211_3.pdf
ย 
Java unit 7
Java unit 7Java unit 7
Java unit 7
ย 
Classes, objects, methods, constructors, this keyword in java
Classes, objects, methods, constructors, this keyword  in javaClasses, objects, methods, constructors, this keyword  in java
Classes, objects, methods, constructors, this keyword in java
ย 
Core Java Introduction | Basics
Core Java Introduction  | BasicsCore Java Introduction  | Basics
Core Java Introduction | Basics
ย 
Java defining classes
Java defining classes Java defining classes
Java defining classes
ย 
Unit 2 Part 1 Constructors.pdf
Unit 2 Part 1 Constructors.pdfUnit 2 Part 1 Constructors.pdf
Unit 2 Part 1 Constructors.pdf
ย 
Java chapter 4
Java chapter 4Java chapter 4
Java chapter 4
ย 
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptxINDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
INDUMATHY- UNIT 1 cs3391 oops introduction to oop and java.pptx
ย 
Ppt chapter05
Ppt chapter05Ppt chapter05
Ppt chapter05
ย 
Delphi qa
Delphi qaDelphi qa
Delphi qa
ย 
Reflection
ReflectionReflection
Reflection
ย 
Unit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptxUnit No 2 Objects and Classes.pptx
Unit No 2 Objects and Classes.pptx
ย 
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3Statics in java | Constructors | Exceptions in Java | String in java| class 3
Statics in java | Constructors | Exceptions in Java | String in java| class 3
ย 
Introduction to Classes and Objects in Java - Edufect
Introduction to Classes and Objects in Java - EdufectIntroduction to Classes and Objects in Java - Edufect
Introduction to Classes and Objects in Java - Edufect
ย 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
ย 

More from omeed

understanding of java basics
understanding of java basics understanding of java basics
understanding of java basics
omeed
ย 
Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
omeed
ย 
Asp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controlsAsp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controls
omeed
ย 
Asp.net CheckBoxList control
Asp.net CheckBoxList controlAsp.net CheckBoxList control
Asp.net CheckBoxList control
omeed
ย 
Asp.net CheckBox control
Asp.net CheckBox controlAsp.net CheckBox control
Asp.net CheckBox control
omeed
ย 
Asp.net RadiobuttonList control
Asp.net RadiobuttonList controlAsp.net RadiobuttonList control
Asp.net RadiobuttonList control
omeed
ย 
Asp.net Radiobutton control
Asp.net Radiobutton controlAsp.net Radiobutton control
Asp.net Radiobutton control
omeed
ย 
Asp.net textbox control
Asp.net textbox controlAsp.net textbox control
Asp.net textbox control
omeed
ย 
Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle
omeed
ย 
Asp.net introduction to web development
Asp.net introduction to web development Asp.net introduction to web development
Asp.net introduction to web development
omeed
ย 
WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language
omeed
ย 
Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri
Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri  Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri
Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri
omeed
ย 
Third and fourth generation programming language
Third and fourth generation programming languageThird and fourth generation programming language
Third and fourth generation programming language
omeed
ย 
analog clock C#
analog clock C#analog clock C#
analog clock C#
omeed
ย 
graphic Design
graphic Design graphic Design
graphic Design
omeed
ย 

More from omeed (15)

understanding of java basics
understanding of java basics understanding of java basics
understanding of java basics
ย 
Introduction to oop using java
Introduction  to oop using java Introduction  to oop using java
Introduction to oop using java
ย 
Asp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controlsAsp.net LinkButton & imageButton controls
Asp.net LinkButton & imageButton controls
ย 
Asp.net CheckBoxList control
Asp.net CheckBoxList controlAsp.net CheckBoxList control
Asp.net CheckBoxList control
ย 
Asp.net CheckBox control
Asp.net CheckBox controlAsp.net CheckBox control
Asp.net CheckBox control
ย 
Asp.net RadiobuttonList control
Asp.net RadiobuttonList controlAsp.net RadiobuttonList control
Asp.net RadiobuttonList control
ย 
Asp.net Radiobutton control
Asp.net Radiobutton controlAsp.net Radiobutton control
Asp.net Radiobutton control
ย 
Asp.net textbox control
Asp.net textbox controlAsp.net textbox control
Asp.net textbox control
ย 
Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle Understanding of Asp.net & page lifecycle
Understanding of Asp.net & page lifecycle
ย 
Asp.net introduction to web development
Asp.net introduction to web development Asp.net introduction to web development
Asp.net introduction to web development
ย 
WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language WEB DEVELOPMENT Using Python programming language
WEB DEVELOPMENT Using Python programming language
ย 
Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri
Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri  Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri
Appleโ€™s AI-Powered Personal Assistant Uses DNN - siri
ย 
Third and fourth generation programming language
Third and fourth generation programming languageThird and fourth generation programming language
Third and fourth generation programming language
ย 
analog clock C#
analog clock C#analog clock C#
analog clock C#
ย 
graphic Design
graphic Design graphic Design
graphic Design
ย 

Recently uploaded

Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
ย 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
ย 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
ย 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
ย 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
ย 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
ย 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
ย 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
ย 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
ย 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
JomonJoseph58
ย 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
ย 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
ย 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
ย 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
ย 
Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...
Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...
Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...
Nguyen Thanh Tu Collection
ย 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
ย 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
ย 
Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...
Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...
Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...
Nguyen Thanh Tu Collection
ย 

Recently uploaded (20)

Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
ย 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
ย 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
ย 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
ย 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
ย 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
ย 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
ย 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
ย 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
ย 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
ย 
Stack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 MicroprocessorStack Memory Organization of 8086 Microprocessor
Stack Memory Organization of 8086 Microprocessor
ย 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
ย 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
ย 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
ย 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
ย 
Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...
Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...
Bร€I TแบฌP Bแป” TRแปข TIแบพNG ANH LแปšP 9 Cแบข Nฤ‚M - GLOBAL SUCCESS - Nฤ‚M HแปŒC 2024-2025 - ...
ย 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
ย 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
ย 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
ย 
Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...
Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...
Bร€I TแบฌP Dแบ Y THรŠM TIแบพNG ANH LแปšP 7 Cแบข Nฤ‚M FRIENDS PLUS SรCH CHร‚N TRแปœI SรNG Tแบ O ...
ย 

OOP using java (Variable in java)

  • 1. OOP - JAVA Variables in Java 4/6/2022 1 Department of Computer PRO โ€“ GRADE 5 Lecturer. OMEED M. M
  • 2. Table of contents ๏ถ What is Variable? ๏ถ Allocating memory ๏ถ Types of variables ๏ถ Constructor 4/6/2022 2
  • 3. Variable in Java Variables used to store in our computerโ€™s memory Why called it variable? Because the values inside the variables are changeable. ๏ƒผ Attributes - things that the object stores data in, generally variables. ๏ƒผ Methods - Functions and Procedures attached to an Object and allowing the object to perform actions 4/6/2022 3
  • 4. Allocating memory In order to store some data in our computer memory we have to allocate some space so how we can do that? we will go through allocating memory, 4/6/2022 4
  • 5. Allocating memory For this purpose we have to declare variables. How we can declare variable we are going to using assignment We can assign a value to a variable by using (Equal =) operator. Ex. String ANY_NAME = โ€œANY_NAMEโ€ 4/6/2022 5
  • 6. Variable in Java โ€ข Re-difine variable 4/6/2022 6
  • 7. Variable in Java โ€ข Println 4/6/2022 7
  • 8. Types of variables There are Three type of variables:- 1. Instance variables 2. Local variables 3. Class variables (Static variables) 4/6/2022 8
  • 9. Instance variables Instance variables Declared inside class but not inside method. Ex. Class test{ Int data=15; //instance variable Float pi=3.114f; //instance variable } Cannot be reinitialized directly within class Ex. Class test{ Int data=15; //instance variable data =20; //Error for correction we have to put it into a method void testMethod(){ data=20 // correct; } } 4/6/2022 9
  • 10. Local variables Local variables โ€“ Declared inside method or method parameters. Ex. Int areatest (int radius){ Int total = radius * radius; Return total; } -These are not accessible outside method. -They did not get default values. 4/6/2022 10
  • 11. Class / Static variables Class variables โˆ’ are variables declared within a class, outside any method, with the static keyword -Static variable is shared between all objects because it belong to the class. It does not belong to the object -A static variable can be accessed without creating an instance of the class. 4/6/2022 11
  • 12. Constructor A constructor in Java is similar to a method that is invoked when an object of the class is created. Unlike Java methods, a constructor has the same name as that of the class and does not have any return type. For example, class Test { Test() { // constructor body } } 4/6/2022 12
  • 13. Types of variables class A{ int date=50; //_________ variable static int m=100; //_________ variable void method(){ int n=90; //________ variable } } //end of class 4/6/2022 13