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

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

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