SlideShare a Scribd company logo
Java Data Types
Features
• There are total 9 Data Types
• Java is a Strongly Typed Language
• No conversion !!!
• This makes it more secure and robust
• Type Compatibility Checking
Strongly Typed
• Every variable has a type
• Every expression is a type
• All assignments are checked for type
• All parameters passing are checked for type
• No confusing conversions
• All type mismatches are error
• Types
boolean either true of false
char16 bit Unicode 1.1
byte8-bit integer (signed)
short 16-bit integer (signed)
int 32-bit integer (signed)
long64-bit integer (singed)
float32-bit floating point (IEEE 754-1985)
double 64-bit floating point (IEEE 754-1985)
String (class for manipulating strings)
Ctegories
Can be classified in four Categories:
• Integers
• Floating Point
• Characters
• Boolean
(They are simple data types not objects) !!!!
Integers
Integers : Width , Usage
• byte : 8 bit , used for stream of data from network and files
• short : 16 bit , rarely used , for 16 bit computers (oudated)
• int : 32 bit, generally used
• long : 64 bit, when integer is not sufficient
In java size does not vary on platform. Though the actual size
taken in memory depends on JVM.
All are signed integers; there are no unsigned integers in java.
Width represents the behaviour , not the amount of space in
memory
Floating Point
Floating Point :
• float : 32 bit
• double : 64 bit
Float
• Single Precision
• Uses 32 bits
• Sometimes faster
• Used when not much accuracy required
Double
• Double Precision
• Uses 64 bits
• Faster on modern processors
• Used in all mathematical calculations
• More Accurate
Characters
Characters:
• char : 16 bit
• Unicode : Contains all characters of all human languages
• No negative characters
• Range 0 to 65,536
• ASCII code is from 0 to 127 which is same for Unicode
till 127.
• ++ /--/+/- operators possible
Boolean
• boolean either true or false
• Not 0 or 1
• Output of all relational and logical operators
Data Type Default Value (for fields)
byte 0
short 0
int 0
long 0L
float 0.0f
double 0.0d
char 'u0000'
String (or any object) null
boolean false
Type Conversion
Automatic Conversion will take place if:
• Two Types are compatible
• Destination is larger than source
• By Default Any Numeric Value is treated as Integer
• By default any Decimal Value is treated as Double
• Still when we assign numeric value to Byte or Short it is
OK, but if we use any value with them … Then byte and
short are converted to int.
• In Float for assignment also f is to be used
• For Long L/l is to be used
Compatible
• Numerals (byte, short, int , long, float, double) are self
compatible but not with char and boolean.
• Char and boolean are not compatible
Casting
Casting is the temporary conversion of a variable
from its original data type to some other data type.
• With primitive data types if a cast is necessary from
a less inclusive data type to a more inclusive data
type it is done automatically if they are compatible.
int x = 5;
double a = 3.5;
double b = a * x + a / x;
double c = x / 2;
• if a cast is necessary from a more inclusive to a less
inclusive data type the class must be done explicitly
by the programmer
double a = 3.5, b = 2.7;
int y = (int) a / (int) b;
y = (int)( a / b );
y = (int) a / b; //syntax error
Type Promotion
17
double
float
long
int
short,
char
byte
Outer ring is most
inclusive data type.
Inner ring is least
inclusive.
In expressions
variables and
sub expressions
of less inclusive
data types are
automatically cast
to more inclusive.
If trying to place
expression that is
more inclusive into
variable that is less
inclusive, explicit cast
must be performed.
From MORE to LESS
Double-……..int
• If either operand is double then other operands are
converted to double
• Otherwise if either operand is float other operands are
converted to float
• Otherwise if either operand is of type long other operands
are converted to long
• Otherwise both operands are converted to int
Problem
• Byte b=50;
b=b * 2;
???????
Casting …
Int a ;
Byte b;
Flaot f;
b=(byte) a;
a = (int) f;
How does it takes place:
1.Reduced Modulo
2. Truncation
Byte b;
Int i=257;
B=(byte ) i;
System.out.println( “Value of b is” + b);
Scope
• Scope is limited to a block
• Block is
{
}
3 Types of variables:
• instance variables : Variable declared inside the class;
Any method in the class definition can access these
variables
• parameter variables Only the method where the
parameter appears can access these variables. This is how
information is passed to the object.
• local variables : Declared inside the method
public class TwoSides
{
int side1, side2 ;
public boolean testRightTriangle( int hypoteneuse )
{
int side1Squared = side1 * side1 ;
int side2Squared = side2 * side2 ;
int hypSquared = hypoteneuse * hypoteneuse ;
}
}
A variable can be declared in/as:
• In a class body as class fields. Variables declared here are
referred to as class-level variables/instance variables.
• As parameters of a method or constructor.
• In a method's body or a constructor's body.
• Within a statement block, such as inside a while or for .
X : Local variable-Block
public class MainClass
{
public static void main(String[] args)
{
for (int x = 0; x < 5; x++)
{
System.out.println(x);
}
}
}
Inner block :Access Outer
Block
public class MainClass
{
public static void main(String[] args)
{
for (int x = 0; x < 5; x++)
{
for (int y = 0; y < 3; y++)
{ // int x; gives an error x already declared in outer block ... Not such in
// C / C++
System.out.println(x);
System.out.println(y);
}
}
}
}
public class MainClass
{
public static void main(String[] args)
{
int outer = 1;
{ int inner = 2;
System.out.println("inner = " + inner);
System.out.println("outer = " + outer);
}
int inner = 3;
System.out.println("inner = " + inner);
System.out.println("outer = " + outer);
}
}
class S
{ int a=5; // instance variable
public void S1()
{ int a=7; // block variable
System.out.println(a); // prints ??
}
}
public class Scope
{ int a=2; // instance variable
public static void main(String args[])
{
S x=new S(); // object x created
x.S1();
int b=5;
System.out.println(b);
}
//System.out.println(a);
// gives an error as a is instance variable and static no object created
} o/p will be 7 7 5 , local variable is given preference over instance variable

More Related Content

What's hot

Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Method overriding
Method overridingMethod overriding
Method overriding
Azaz Maverick
 
StringTokenizer in java
StringTokenizer in javaStringTokenizer in java
StringTokenizer in java
Muthukumaran Subramanian
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
Pratik Soares
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
tanu_jaswal
 
PHP variables
PHP  variablesPHP  variables
PHP variables
Siddique Ibrahim
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
JayasankarPR2
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
Nahian Ahmed
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
Marcello Thiry
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
Benj Del Mundo
 
Dtd
DtdDtd
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
Aakash Ugale
 
Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Collections and its types in C# (with examples)
Collections and its types in C# (with examples)
Aijaz Ali Abro
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
TMARAGATHAM
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
DrRajeshreeKhande
 

What's hot (20)

Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Method overriding
Method overridingMethod overriding
Method overriding
 
StringTokenizer in java
StringTokenizer in javaStringTokenizer in java
StringTokenizer in java
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
PHP variables
PHP  variablesPHP  variables
PHP variables
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
java.io - streams and files
java.io - streams and filesjava.io - streams and files
java.io - streams and files
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Java Thread Synchronization
Java Thread SynchronizationJava Thread Synchronization
Java Thread Synchronization
 
Dtd
DtdDtd
Dtd
 
Data Storage In Android
Data Storage In Android Data Storage In Android
Data Storage In Android
 
Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Collections and its types in C# (with examples)
Collections and its types in C# (with examples)
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 

Viewers also liked

02 data types in java
02 data types in java02 data types in java
02 data types in java
রাকিন রাকিন
 
Java Class 2
Java Class 2Java Class 2
Java Class 2
Mayank Aggarwal
 
Java Class1
Java Class1Java Class1
Java Class1
Mayank Aggarwal
 
Datatype introduction- JAVA
Datatype introduction- JAVADatatype introduction- JAVA
Datatype introduction- JAVA
Hamna_sheikh
 
Java Classes
Java ClassesJava Classes
Java Classes
Mayank Aggarwal
 
Presentation
PresentationPresentation
Presentation
Fiaz Khokhar
 
Java
JavaJava
Java
kavirishi
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
teach4uin
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
Thooyavan Venkatachalam
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
Ahmad Idrees
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
Arc Keepers Solutions
 
Virtualization: Force driving cloud computing
Virtualization: Force driving cloud computingVirtualization: Force driving cloud computing
Virtualization: Force driving cloud computing
Mayank Aggarwal
 
Java - Operators
Java - OperatorsJava - Operators
Java - Operators
Preethi Nambiar
 
OCA JAVA - 3 Programming with Java Operators
 OCA JAVA - 3 Programming with Java Operators OCA JAVA - 3 Programming with Java Operators
OCA JAVA - 3 Programming with Java Operators
Fernando Gil
 
Aae oop xp_04
Aae oop xp_04Aae oop xp_04
Aae oop xp_04
Niit Care
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
TAlha MAlik
 
Cloud Computing : Revised Presentation
Cloud Computing : Revised PresentationCloud Computing : Revised Presentation
Cloud Computing : Revised Presentation
Mayank Aggarwal
 
Java features
Java featuresJava features
Java features
myrajendra
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
Tareq Hasan
 
Cloudsim modified
Cloudsim modifiedCloudsim modified
Cloudsim modified
Mayank Aggarwal
 

Viewers also liked (20)

02 data types in java
02 data types in java02 data types in java
02 data types in java
 
Java Class 2
Java Class 2Java Class 2
Java Class 2
 
Java Class1
Java Class1Java Class1
Java Class1
 
Datatype introduction- JAVA
Datatype introduction- JAVADatatype introduction- JAVA
Datatype introduction- JAVA
 
Java Classes
Java ClassesJava Classes
Java Classes
 
Presentation
PresentationPresentation
Presentation
 
Java
JavaJava
Java
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Virtualization: Force driving cloud computing
Virtualization: Force driving cloud computingVirtualization: Force driving cloud computing
Virtualization: Force driving cloud computing
 
Java - Operators
Java - OperatorsJava - Operators
Java - Operators
 
OCA JAVA - 3 Programming with Java Operators
 OCA JAVA - 3 Programming with Java Operators OCA JAVA - 3 Programming with Java Operators
OCA JAVA - 3 Programming with Java Operators
 
Aae oop xp_04
Aae oop xp_04Aae oop xp_04
Aae oop xp_04
 
Cs1123 6 loops
Cs1123 6 loopsCs1123 6 loops
Cs1123 6 loops
 
Cloud Computing : Revised Presentation
Cloud Computing : Revised PresentationCloud Computing : Revised Presentation
Cloud Computing : Revised Presentation
 
Java features
Java featuresJava features
Java features
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
Cloudsim modified
Cloudsim modifiedCloudsim modified
Cloudsim modified
 

Similar to Java Datatypes

java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
Raja Sekhar
 
JavaVariablesTypes.pptx
JavaVariablesTypes.pptxJavaVariablesTypes.pptx
JavaVariablesTypes.pptx
charusharma165
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
raksharao
 
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptxOOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
AhmedMehmood35
 
Chapter02.PPT
Chapter02.PPTChapter02.PPT
Chapter02.PPT
Chaitanya Jambotkar
 
c programming 2nd chapter pdf.PPT
c programming 2nd chapter pdf.PPTc programming 2nd chapter pdf.PPT
c programming 2nd chapter pdf.PPT
KauserJahan6
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C ProgrammingIntroduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
Eric Chou
 
BASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their ownBASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their own
Nandini485510
 
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4
FabMinds
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ayshwarya Baburam
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
Hari Christian
 
C language
C languageC language
C language
Robo India
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
rohassanie
 
Javascript
JavascriptJavascript
Javascript
Sunil Thakur
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
Connex
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
marvellous2
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
Ronaldo Aditya
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
ssuserb1a18d
 

Similar to Java Datatypes (20)

java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
 
JavaVariablesTypes.pptx
JavaVariablesTypes.pptxJavaVariablesTypes.pptx
JavaVariablesTypes.pptx
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptxOOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
 
Chapter02.PPT
Chapter02.PPTChapter02.PPT
Chapter02.PPT
 
c programming 2nd chapter pdf.PPT
c programming 2nd chapter pdf.PPTc programming 2nd chapter pdf.PPT
c programming 2nd chapter pdf.PPT
 
Introduction to Problem Solving C Programming
Introduction to Problem Solving C ProgrammingIntroduction to Problem Solving C Programming
Introduction to Problem Solving C Programming
 
A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...A File is a collection of data stored in the secondary memory. So far data wa...
A File is a collection of data stored in the secondary memory. So far data wa...
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
BASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their ownBASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their own
 
Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4Python Programming | JNTUK | UNIT 1 | Lecture 4
Python Programming | JNTUK | UNIT 1 | Lecture 4
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
C language
C languageC language
C language
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
Javascript
JavascriptJavascript
Javascript
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 

Recently uploaded

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
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
 
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
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
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
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
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
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
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
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
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
 

Recently uploaded (20)

Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
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
 
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
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
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!
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
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
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
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
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 

Java Datatypes

  • 2. Features • There are total 9 Data Types • Java is a Strongly Typed Language • No conversion !!! • This makes it more secure and robust • Type Compatibility Checking
  • 3. Strongly Typed • Every variable has a type • Every expression is a type • All assignments are checked for type • All parameters passing are checked for type • No confusing conversions • All type mismatches are error
  • 4. • Types boolean either true of false char16 bit Unicode 1.1 byte8-bit integer (signed) short 16-bit integer (signed) int 32-bit integer (signed) long64-bit integer (singed) float32-bit floating point (IEEE 754-1985) double 64-bit floating point (IEEE 754-1985) String (class for manipulating strings)
  • 5. Ctegories Can be classified in four Categories: • Integers • Floating Point • Characters • Boolean (They are simple data types not objects) !!!!
  • 6. Integers Integers : Width , Usage • byte : 8 bit , used for stream of data from network and files • short : 16 bit , rarely used , for 16 bit computers (oudated) • int : 32 bit, generally used • long : 64 bit, when integer is not sufficient In java size does not vary on platform. Though the actual size taken in memory depends on JVM. All are signed integers; there are no unsigned integers in java. Width represents the behaviour , not the amount of space in memory
  • 7. Floating Point Floating Point : • float : 32 bit • double : 64 bit
  • 8. Float • Single Precision • Uses 32 bits • Sometimes faster • Used when not much accuracy required
  • 9. Double • Double Precision • Uses 64 bits • Faster on modern processors • Used in all mathematical calculations • More Accurate
  • 10. Characters Characters: • char : 16 bit • Unicode : Contains all characters of all human languages • No negative characters • Range 0 to 65,536 • ASCII code is from 0 to 127 which is same for Unicode till 127. • ++ /--/+/- operators possible
  • 11. Boolean • boolean either true or false • Not 0 or 1 • Output of all relational and logical operators
  • 12. Data Type Default Value (for fields) byte 0 short 0 int 0 long 0L float 0.0f double 0.0d char 'u0000' String (or any object) null boolean false
  • 13. Type Conversion Automatic Conversion will take place if: • Two Types are compatible • Destination is larger than source
  • 14. • By Default Any Numeric Value is treated as Integer • By default any Decimal Value is treated as Double • Still when we assign numeric value to Byte or Short it is OK, but if we use any value with them … Then byte and short are converted to int. • In Float for assignment also f is to be used • For Long L/l is to be used
  • 15. Compatible • Numerals (byte, short, int , long, float, double) are self compatible but not with char and boolean. • Char and boolean are not compatible
  • 16. Casting Casting is the temporary conversion of a variable from its original data type to some other data type. • With primitive data types if a cast is necessary from a less inclusive data type to a more inclusive data type it is done automatically if they are compatible. int x = 5; double a = 3.5; double b = a * x + a / x; double c = x / 2; • if a cast is necessary from a more inclusive to a less inclusive data type the class must be done explicitly by the programmer double a = 3.5, b = 2.7; int y = (int) a / (int) b; y = (int)( a / b ); y = (int) a / b; //syntax error
  • 17. Type Promotion 17 double float long int short, char byte Outer ring is most inclusive data type. Inner ring is least inclusive. In expressions variables and sub expressions of less inclusive data types are automatically cast to more inclusive. If trying to place expression that is more inclusive into variable that is less inclusive, explicit cast must be performed. From MORE to LESS
  • 18. Double-……..int • If either operand is double then other operands are converted to double • Otherwise if either operand is float other operands are converted to float • Otherwise if either operand is of type long other operands are converted to long • Otherwise both operands are converted to int
  • 20. Casting … Int a ; Byte b; Flaot f; b=(byte) a; a = (int) f; How does it takes place: 1.Reduced Modulo 2. Truncation
  • 21. Byte b; Int i=257; B=(byte ) i; System.out.println( “Value of b is” + b);
  • 22. Scope • Scope is limited to a block • Block is { }
  • 23. 3 Types of variables: • instance variables : Variable declared inside the class; Any method in the class definition can access these variables • parameter variables Only the method where the parameter appears can access these variables. This is how information is passed to the object. • local variables : Declared inside the method
  • 24. public class TwoSides { int side1, side2 ; public boolean testRightTriangle( int hypoteneuse ) { int side1Squared = side1 * side1 ; int side2Squared = side2 * side2 ; int hypSquared = hypoteneuse * hypoteneuse ; } }
  • 25. A variable can be declared in/as: • In a class body as class fields. Variables declared here are referred to as class-level variables/instance variables. • As parameters of a method or constructor. • In a method's body or a constructor's body. • Within a statement block, such as inside a while or for .
  • 26. X : Local variable-Block public class MainClass { public static void main(String[] args) { for (int x = 0; x < 5; x++) { System.out.println(x); } } }
  • 27. Inner block :Access Outer Block public class MainClass { public static void main(String[] args) { for (int x = 0; x < 5; x++) { for (int y = 0; y < 3; y++) { // int x; gives an error x already declared in outer block ... Not such in // C / C++ System.out.println(x); System.out.println(y); } } } }
  • 28. public class MainClass { public static void main(String[] args) { int outer = 1; { int inner = 2; System.out.println("inner = " + inner); System.out.println("outer = " + outer); } int inner = 3; System.out.println("inner = " + inner); System.out.println("outer = " + outer); } }
  • 29. class S { int a=5; // instance variable public void S1() { int a=7; // block variable System.out.println(a); // prints ?? } } public class Scope { int a=2; // instance variable public static void main(String args[]) { S x=new S(); // object x created x.S1(); int b=5; System.out.println(b); } //System.out.println(a); // gives an error as a is instance variable and static no object created } o/p will be 7 7 5 , local variable is given preference over instance variable