SlideShare a Scribd company logo
Java Variables & Class
Kadarkarai Selvam
❖ Container to hold value. Assigned with data type
❖ Reserved Area allocated in memory
Int x = 10;
RAM
Java Variable
Reserved place for
variable X to store
value
Java Example
public class SumofNumbers
{
public static void main(String args[])
{
int i = 20, j = 15, sum;
sum = i + j;
System.out.println("The sum of numbers is: "+sum);
}
}
I, J, sum are variables
which can hold value
and of type Integer
Java Primitive Data type
❖ Specifies the container size and characteristics to store the values
❖ Primitive Data type - Basic entity to store the data
❖ Primitive Data type includes
➢ Boolean
➢ Char
➢ Byte, Short, Int, Long
➢ Float & Double
Java Primitive Data type
Data Type Default value Default Size Example
boolean false 1 bit boolean a = false;
char 'u0000' 2 byte
'u0000' (or 0) to 'uffff' (or 65,535)
char c = 'c';
byte 0 1 byte (-128 to 127) byte num1=127;
short 0 2 byte (-32,768 to 32,767) short s = 10000;
int 0 4 byte (2,147,483,648 (-2^31) to
2,147,483,647 (2^31 -1))
int i = 100000;
long 0L 8 byte (-9,223,372,036,854,775,808(-
2^63) to 9,223,372,036,854,775,807(2^63 -
1))
long l = 100000L;
float 0.0f 4 byte (unlimited) float f1 = 234.5f;
double 0.0d 8 byte (unlimited) double d1 = 12.3
Java Non Primitive Data type
❖ Used to store a group of values
❖ These Data types are not Pre defined in JAVA
❖ Few Examples are
➢ Class
➢ Array
➢ String
➢ Interface
Object
❖ Object have
➢ State : data of an object
➢ Behaviour : functionally of an object
➢ Identity : unique id used by JVM
❖ Object is an instance of a class
❖ E.g., Xiaomi Redmi 10 is an Object which have
➢ Size : 6.5 Inches (state)
➢ Ram memory : 4GB and 6GB (state)
➢ Warp Charging (behaviour)
➢ Dual standby (behaviour)
Class
❖ Group of Object which have common properties
❖ Boilerplate or Template or Blueprint for objects to get created
State and Behaviour Xiaomi Redmi 10 ABC mobile model
Ram 6GB and 4GB 2GB
Size 6.5 inches 5 inches
Standby Dual standby Single Standby
GPU Mali-G52 MC2 -
Class Components
❖ Variable : Reserved Memory location to hold values
❖ Constructor
➢ Special method and Used to initialize an object.
➢ If Constructor is not declared, then Java compiler will create default constructor
❖ Methods
➢ Block of code where parameters can be passed.
➢ Only runs when it is called. These are called Functions
➢ It represents the Behavior of an object and it supports code reusability and Optimization
public class Phones {
int Ram;
float size;
String Name, GPU;
static String type = "Android";
Phones(String N, int R, float S, String G) {
Ram = R;
size = S;
Name = N;
GPU = G;
}
void knowmyphone() {
String sim = "Dual Sim";
System.out.println("Phone Name :"+Name);
System.out.println("Operating System :"+type);
System.out.println("Sim card slot :"+sim);
System.out.println("Size in inches : "+size);
System.out.println("Ram memory : "+Ram);
System.out.println("GPU value : "+GPU);
}
public static void main(String args[]) {
Phones p1 = new Phones("Redmi Note 10",6,6.5f,"");
p1.knowmyphone();
Phones p2 = new Phones("OnePlus 9
pro",12,6.7f,"Adreno 660");
p2.knowmyphone();
}
//Instance Variable
//Static Variable
//local Variable
Variable Type
❖ Local Variable : Only within a Method. Other methods or outside the
method doesn’t know about the variable
❖ Instance Variable : Inside the class but outside the method. It is instance
specific i.e., Different Objects have Different values if it is not declared
❖ Static Variable : Single copy of variable. Memory is allocated when the
class is loaded. i.e, same value for all objects.

More Related Content

What's hot

An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
Abhishek Asthana
 
JAVA CLASS1
JAVA CLASS1JAVA CLASS1
JAVA CLASS1
Prudhvi Akella
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
SadhanaParameswaran
 
Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVM
kensipe
 
Practical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profilingPractical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profiling
Lubomir Rintel
 
JAVA BYTE CODE
JAVA BYTE CODEJAVA BYTE CODE
JAVA BYTE CODE
Javed Ahmed Samo
 
Dynamic Proxy by Java
Dynamic Proxy by JavaDynamic Proxy by Java
Dynamic Proxy by Java
Kan-Han (John) Lu
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
Shashank L
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
yoavwix
 
15 darwino script & command line
15   darwino script & command line15   darwino script & command line
15 darwino script & command line
darwinodb
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
Marcelo Ochoa
 
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Hisham Mardam-Bey
 
JavaOne 2011 Recap
JavaOne 2011 RecapJavaOne 2011 Recap
JavaOne 2011 Recap
Jim Bethancourt
 
Java ce241
Java ce241Java ce241
Java ce241
Minal Maniar
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
Fuqiang Wang
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
HuffPost Code
 
Javaforum looking into the memory
Javaforum   looking into the memoryJavaforum   looking into the memory
Javaforum looking into the memory
Squeed
 
Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Continuations in scala (incomplete version)
Continuations in scala (incomplete version)
Fuqiang Wang
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
Hp java heap dump analysis Workshop
Hp java heap dump analysis WorkshopHp java heap dump analysis Workshop
Hp java heap dump analysis Workshop
Madhavan Marimuthu
 

What's hot (20)

An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
 
JAVA CLASS1
JAVA CLASS1JAVA CLASS1
JAVA CLASS1
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Debugging Your Production JVM
Debugging Your Production JVMDebugging Your Production JVM
Debugging Your Production JVM
 
Practical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profilingPractical SystemTAP basics: Perl memory profiling
Practical SystemTAP basics: Perl memory profiling
 
JAVA BYTE CODE
JAVA BYTE CODEJAVA BYTE CODE
JAVA BYTE CODE
 
Dynamic Proxy by Java
Dynamic Proxy by JavaDynamic Proxy by Java
Dynamic Proxy by Java
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
 
15 darwino script & command line
15   darwino script & command line15   darwino script & command line
15 darwino script & command line
 
Experiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the DatabaseExperiences with Evangelizing Java Within the Database
Experiences with Evangelizing Java Within the Database
 
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...Type safe, versioned, and rewindable stream processing  with  Apache {Avro, K...
Type safe, versioned, and rewindable stream processing with Apache {Avro, K...
 
JavaOne 2011 Recap
JavaOne 2011 RecapJavaOne 2011 Recap
JavaOne 2011 Recap
 
Java ce241
Java ce241Java ce241
Java ce241
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
 
Javaforum looking into the memory
Javaforum   looking into the memoryJavaforum   looking into the memory
Javaforum looking into the memory
 
Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Continuations in scala (incomplete version)
Continuations in scala (incomplete version)
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Hp java heap dump analysis Workshop
Hp java heap dump analysis WorkshopHp java heap dump analysis Workshop
Hp java heap dump analysis Workshop
 

Similar to Java variables and classes

Computational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptxComputational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptx
320126552027SURAKATT
 
Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
Rajesh Verma
 
Java PSkills-session2.pptx
Java PSkills-session2.pptxJava PSkills-session2.pptx
Java PSkills-session2.pptx
ssuser99ca78
 
C++ theory
C++ theoryC++ theory
C++ theory
Shyam Khant
 
C language basics
C language basicsC language basics
C language basics
Nikshithas R
 
Computational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdfComputational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdf
SadhikaPolamarasetti1
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
ssuserb1a18d
 
Unit 1
Unit 1Unit 1
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
SadhanaParameswaran
 
02 data types in java
02 data types in java02 data types in java
02 data types in java
রাকিন রাকিন
 
Class 8 - Java.pptx
Class 8 - Java.pptxClass 8 - Java.pptx
Class 8 - Java.pptx
sreedevi143432
 
RealmDB for Android
RealmDB for AndroidRealmDB for Android
RealmDB for Android
GlobalLogic Ukraine
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
sunny khan
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
Mahika Tutorials
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
Infoviaan Technologies
 
Core java
Core javaCore java
Core java
Mallikarjuna G D
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 

Similar to Java variables and classes (20)

Computational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptxComputational Problem Solving 016 (1).pptx
Computational Problem Solving 016 (1).pptx
 
Java Intro
Java IntroJava Intro
Java Intro
 
Shiksharth com java_topics
Shiksharth com java_topicsShiksharth com java_topics
Shiksharth com java_topics
 
Java PSkills-session2.pptx
Java PSkills-session2.pptxJava PSkills-session2.pptx
Java PSkills-session2.pptx
 
C++ theory
C++ theoryC++ theory
C++ theory
 
C language basics
C language basicsC language basics
C language basics
 
Computational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdfComputational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdf
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 
Unit 1
Unit 1Unit 1
Unit 1
 
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
 
02 data types in java
02 data types in java02 data types in java
02 data types in java
 
Class 8 - Java.pptx
Class 8 - Java.pptxClass 8 - Java.pptx
Class 8 - Java.pptx
 
RealmDB for Android
RealmDB for AndroidRealmDB for Android
RealmDB for Android
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Variables and Data Types
Variables and Data TypesVariables and Data Types
Variables and Data Types
 
Core java
Core javaCore java
Core java
 
Fundamentals of Programming Constructs.pptx
Fundamentals of  Programming Constructs.pptxFundamentals of  Programming Constructs.pptx
Fundamentals of Programming Constructs.pptx
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 

More from KadarkaraiSelvam

Selenium web driver useful commands
Selenium web driver useful commandsSelenium web driver useful commands
Selenium web driver useful commands
KadarkaraiSelvam
 
Java 2
Java 2Java 2
Java 1
Java 1Java 1
Java selenium web driver
Java selenium web driverJava selenium web driver
Java selenium web driver
KadarkaraiSelvam
 
Selenium inputs
Selenium inputsSelenium inputs
Selenium inputs
KadarkaraiSelvam
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
KadarkaraiSelvam
 
Maven and versioning
Maven and versioningMaven and versioning
Maven and versioning
KadarkaraiSelvam
 
Java Inheritance and Polymorphism
Java Inheritance and PolymorphismJava Inheritance and Polymorphism
Java Inheritance and Polymorphism
KadarkaraiSelvam
 
Java Control Statements
Java Control StatementsJava Control Statements
Java Control Statements
KadarkaraiSelvam
 
Java JVM
Java JVMJava JVM
Selenium ide 1
Selenium ide 1Selenium ide 1
Selenium ide 1
KadarkaraiSelvam
 

More from KadarkaraiSelvam (11)

Selenium web driver useful commands
Selenium web driver useful commandsSelenium web driver useful commands
Selenium web driver useful commands
 
Java 2
Java 2Java 2
Java 2
 
Java 1
Java 1Java 1
Java 1
 
Java selenium web driver
Java selenium web driverJava selenium web driver
Java selenium web driver
 
Selenium inputs
Selenium inputsSelenium inputs
Selenium inputs
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
 
Maven and versioning
Maven and versioningMaven and versioning
Maven and versioning
 
Java Inheritance and Polymorphism
Java Inheritance and PolymorphismJava Inheritance and Polymorphism
Java Inheritance and Polymorphism
 
Java Control Statements
Java Control StatementsJava Control Statements
Java Control Statements
 
Java JVM
Java JVMJava JVM
Java JVM
 
Selenium ide 1
Selenium ide 1Selenium ide 1
Selenium ide 1
 

Recently uploaded

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 

Recently uploaded (20)

Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 

Java variables and classes

  • 1. Java Variables & Class Kadarkarai Selvam
  • 2. ❖ Container to hold value. Assigned with data type ❖ Reserved Area allocated in memory Int x = 10; RAM Java Variable Reserved place for variable X to store value
  • 3. Java Example public class SumofNumbers { public static void main(String args[]) { int i = 20, j = 15, sum; sum = i + j; System.out.println("The sum of numbers is: "+sum); } } I, J, sum are variables which can hold value and of type Integer
  • 4. Java Primitive Data type ❖ Specifies the container size and characteristics to store the values ❖ Primitive Data type - Basic entity to store the data ❖ Primitive Data type includes ➢ Boolean ➢ Char ➢ Byte, Short, Int, Long ➢ Float & Double
  • 5. Java Primitive Data type Data Type Default value Default Size Example boolean false 1 bit boolean a = false; char 'u0000' 2 byte 'u0000' (or 0) to 'uffff' (or 65,535) char c = 'c'; byte 0 1 byte (-128 to 127) byte num1=127; short 0 2 byte (-32,768 to 32,767) short s = 10000; int 0 4 byte (2,147,483,648 (-2^31) to 2,147,483,647 (2^31 -1)) int i = 100000; long 0L 8 byte (-9,223,372,036,854,775,808(- 2^63) to 9,223,372,036,854,775,807(2^63 - 1)) long l = 100000L; float 0.0f 4 byte (unlimited) float f1 = 234.5f; double 0.0d 8 byte (unlimited) double d1 = 12.3
  • 6. Java Non Primitive Data type ❖ Used to store a group of values ❖ These Data types are not Pre defined in JAVA ❖ Few Examples are ➢ Class ➢ Array ➢ String ➢ Interface
  • 7. Object ❖ Object have ➢ State : data of an object ➢ Behaviour : functionally of an object ➢ Identity : unique id used by JVM ❖ Object is an instance of a class ❖ E.g., Xiaomi Redmi 10 is an Object which have ➢ Size : 6.5 Inches (state) ➢ Ram memory : 4GB and 6GB (state) ➢ Warp Charging (behaviour) ➢ Dual standby (behaviour)
  • 8. Class ❖ Group of Object which have common properties ❖ Boilerplate or Template or Blueprint for objects to get created State and Behaviour Xiaomi Redmi 10 ABC mobile model Ram 6GB and 4GB 2GB Size 6.5 inches 5 inches Standby Dual standby Single Standby GPU Mali-G52 MC2 -
  • 9. Class Components ❖ Variable : Reserved Memory location to hold values ❖ Constructor ➢ Special method and Used to initialize an object. ➢ If Constructor is not declared, then Java compiler will create default constructor ❖ Methods ➢ Block of code where parameters can be passed. ➢ Only runs when it is called. These are called Functions ➢ It represents the Behavior of an object and it supports code reusability and Optimization
  • 10. public class Phones { int Ram; float size; String Name, GPU; static String type = "Android"; Phones(String N, int R, float S, String G) { Ram = R; size = S; Name = N; GPU = G; } void knowmyphone() { String sim = "Dual Sim"; System.out.println("Phone Name :"+Name); System.out.println("Operating System :"+type); System.out.println("Sim card slot :"+sim); System.out.println("Size in inches : "+size); System.out.println("Ram memory : "+Ram); System.out.println("GPU value : "+GPU); } public static void main(String args[]) { Phones p1 = new Phones("Redmi Note 10",6,6.5f,""); p1.knowmyphone(); Phones p2 = new Phones("OnePlus 9 pro",12,6.7f,"Adreno 660"); p2.knowmyphone(); } //Instance Variable //Static Variable //local Variable
  • 11. Variable Type ❖ Local Variable : Only within a Method. Other methods or outside the method doesn’t know about the variable ❖ Instance Variable : Inside the class but outside the method. It is instance specific i.e., Different Objects have Different values if it is not declared ❖ Static Variable : Single copy of variable. Memory is allocated when the class is loaded. i.e, same value for all objects.

Editor's Notes

  1. Two data type - Primitive and Non Primitive.
  2. Byte - handle the stream of data from a network or file Short - to save memory as int is the default data type for numbers Float - If you want to save memory use float instead of double Float and double data types should never be used for precise values such as currency
  3. Classes and Objects are basic components of Object Oriented programming Object is the physical and logical entity whereas class is an logical entity only I.e, Object is a real world entity
  4. A constructor must be the same name of a Java class. It does not have a return type.