SlideShare a Scribd company logo
1 of 20
Download to read offline
Nihar Ranjan Roy
Data Types
Primitives
(Standard)
Numeric
Integer
byte short int long
Floa
t
float double
Non-
Numeric
char boolean
Non-Primitives
(Derived)
Array Class Interfaces
Unicode16 bits i.e. 65,536 characters
Identifiers are the names given to elements like class , methods,
variables etc.
Rules
1. Variable name must begin with a letter, a doller symbol or an
under Score, which can be followed by a sequence of letters or
digits or, $ or _
2. It must be unique
3. It can be of any length
4. There should not be any space in between
5. Key words cannot be used
6. Java is case sensitive
Decimal(10) ex 23,-34,0, 1234
Octal (8) ex 023,034
Hexa Decimal(16) ex OX23,OX34
Standard Example 2.4double , 3.5FFloat
Scientific Example 2.4E7, 56e5
true or false
‘a’,’B’,’t’,’u0064’Hexa,’141’octal
“nihar Ranjan Roy”
Operator Symbols
Arithmetic
Assignment
Comparison
Unary
Shift
Bitwise
Logical
Conditional
Instance of and (.)
new
+,-,/,*,%
=,+=,-=,/=,*=
<,>,<=,>=,==,!=
++,--
>>,<<,>>>
AND,OR,NOT,XOR(&,|,~,^)
&&,||
Test Cond?Expr1:Expr2;
Obj instanceof class,.
Rose obj=new Rose();
13%5=?
13%-5=?
-13%-5=?
-13% 5=?
Positive number right shift
13>>1
13(1101)2
0000 1101 shift by 1 place
0000 01106
Positive number left shift
13<<1
0000 1101
0001 101026
Trick no/2n
13/21=13/2=6
Trick 2n*no
check 21*13=26
Negative number right shift
-10>>2
-10<<2
100000 1010
-10?
Rule Change 01 and 10 for all bits except the right most
bit that starts with 1
-101111 0110
-10>>21111 1101=-3
-10<<21101 1000=-40
Trick
-10/2n=-10/4=-2.5= -3
-10*2n=10*4=-40
100000 1010
-101111 0110
It does not distinguish between + and –ve numbers
10>>>2=0000 0010=2
-10>>>2
00111111 11111111 11111111 11111111=1073741821
Conclusion it places 0’s at MSB
Write a program in java that finds the sum of
the digits of an integer number till the sum
comes to single digit
Note  D0not use any Loop
Example
12345=1+2+3+4+5=15=1+5=6
float var=100.34;
Int a=(int) var;
Statement Keywords
Decision Making if , if else, switch
Loop for , while, do while
Exception try, catch, finally
Miscellaneous( others) break, continue ,return,
label
Switch If else
It can test only equality It evaluates any type of
Boolean expression
Break is needed Break is not needed
More efficient way of
represent branching
Less efficient way
It is faster Its slower
U cannot use a range of
values easily
U can use range of
values
Causes the flow to exit from the loop
…….
for ( int I =0;i<5;i++)
{
If (i==3)
break;
}
……..
Int i=6;
one:
{
System.out.println(“inside one”);
two:
{
System.out.println(“inside one”);
if (i==3)
break one;
}
}
Test
with in
loop
for (int i=0;i<50;i++)
{
If (i%2==0)
continue;
else
Sum+=I;
}
A frog starts climbing 30 ft well. Each hour frog
climbs 3ft and slips back 2ft. How many hours
does it take to reach top and get out?
[Hint: if Height>30 break;]
[Hint: sum of cubes of individual digits
give same number.
153=13+53+33=1+125+27=153]
Write a java program to find the
Armstrong number from 100 to 1000

More Related Content

Similar to 02_Data Types in java.pdf

Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
JavaVariablesTypes.pptx
JavaVariablesTypes.pptxJavaVariablesTypes.pptx
JavaVariablesTypes.pptxcharusharma165
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignmentmcollison
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysDevaKumari Vijay
 
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfBasic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfComputer Programmer
 
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...GANESHBABUVelu
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02CIMAP
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and OperatorsMarwa Ali Eissa
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data TypesTareq Hasan
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfEjazAlam23
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckseidounsemel
 

Similar to 02_Data Types in java.pdf (20)

Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
JavaVariablesTypes.pptx
JavaVariablesTypes.pptxJavaVariablesTypes.pptx
JavaVariablesTypes.pptx
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
130706266060138191
130706266060138191130706266060138191
130706266060138191
 
Pythonintro
PythonintroPythonintro
Pythonintro
 
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdfBasic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
Basic_C++ Notes with problema from Preethi arora and suneetha arora.pdf
 
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.) I...
 
java notes.pdf
java notes.pdfjava notes.pdf
java notes.pdf
 
Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02Claguage 110226222227-phpapp02
Claguage 110226222227-phpapp02
 
Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
130707833146508191
130707833146508191130707833146508191
130707833146508191
 
kotlin-nutshell.pptx
kotlin-nutshell.pptxkotlin-nutshell.pptx
kotlin-nutshell.pptx
 
2 1 data
2 1  data2 1  data
2 1 data
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
C language
C languageC language
C language
 
TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ck
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

02_Data Types in java.pdf

  • 2. Data Types Primitives (Standard) Numeric Integer byte short int long Floa t float double Non- Numeric char boolean Non-Primitives (Derived) Array Class Interfaces
  • 3. Unicode16 bits i.e. 65,536 characters
  • 4.
  • 5. Identifiers are the names given to elements like class , methods, variables etc. Rules 1. Variable name must begin with a letter, a doller symbol or an under Score, which can be followed by a sequence of letters or digits or, $ or _ 2. It must be unique 3. It can be of any length 4. There should not be any space in between 5. Key words cannot be used 6. Java is case sensitive
  • 6. Decimal(10) ex 23,-34,0, 1234 Octal (8) ex 023,034 Hexa Decimal(16) ex OX23,OX34 Standard Example 2.4double , 3.5FFloat Scientific Example 2.4E7, 56e5 true or false ‘a’,’B’,’t’,’u0064’Hexa,’141’octal “nihar Ranjan Roy”
  • 7. Operator Symbols Arithmetic Assignment Comparison Unary Shift Bitwise Logical Conditional Instance of and (.) new +,-,/,*,% =,+=,-=,/=,*= <,>,<=,>=,==,!= ++,-- >>,<<,>>> AND,OR,NOT,XOR(&,|,~,^) &&,|| Test Cond?Expr1:Expr2; Obj instanceof class,. Rose obj=new Rose();
  • 9. Positive number right shift 13>>1 13(1101)2 0000 1101 shift by 1 place 0000 01106 Positive number left shift 13<<1 0000 1101 0001 101026 Trick no/2n 13/21=13/2=6 Trick 2n*no check 21*13=26
  • 10. Negative number right shift -10>>2 -10<<2 100000 1010 -10? Rule Change 01 and 10 for all bits except the right most bit that starts with 1 -101111 0110 -10>>21111 1101=-3 -10<<21101 1000=-40 Trick -10/2n=-10/4=-2.5= -3 -10*2n=10*4=-40
  • 11. 100000 1010 -101111 0110 It does not distinguish between + and –ve numbers 10>>>2=0000 0010=2 -10>>>2 00111111 11111111 11111111 11111111=1073741821 Conclusion it places 0’s at MSB
  • 12. Write a program in java that finds the sum of the digits of an integer number till the sum comes to single digit Note  D0not use any Loop Example 12345=1+2+3+4+5=15=1+5=6
  • 14.
  • 15. Statement Keywords Decision Making if , if else, switch Loop for , while, do while Exception try, catch, finally Miscellaneous( others) break, continue ,return, label
  • 16. Switch If else It can test only equality It evaluates any type of Boolean expression Break is needed Break is not needed More efficient way of represent branching Less efficient way It is faster Its slower U cannot use a range of values easily U can use range of values
  • 17. Causes the flow to exit from the loop ……. for ( int I =0;i<5;i++) { If (i==3) break; } …….. Int i=6; one: { System.out.println(“inside one”); two: { System.out.println(“inside one”); if (i==3) break one; } }
  • 18. Test with in loop for (int i=0;i<50;i++) { If (i%2==0) continue; else Sum+=I; }
  • 19. A frog starts climbing 30 ft well. Each hour frog climbs 3ft and slips back 2ft. How many hours does it take to reach top and get out? [Hint: if Height>30 break;]
  • 20. [Hint: sum of cubes of individual digits give same number. 153=13+53+33=1+125+27=153] Write a java program to find the Armstrong number from 100 to 1000