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

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

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