SlideShare a Scribd company logo
Type Conversion, Casting,
Parsing
1
www.infoviaan.com
Small to big data type
• Will be done automatically
• int i = 5;
• double d = i;
• short s = 10;
• int i = s;
• long l = i;
2
www.infoviaan.com
Program - Automatic Converting
public class AutomaticConversion{
public static void main(String args[]){
int i = 89;
float f = i / 2.5f;
double d = f;
System.out.println("integer : "+i);
System.out.println("float : "+ f);
System.out.println("double : "+ d);
}
}
3
www.infoviaan.com
Big to Small data type
When precision or data loss likely to happen then
type casting is required.
• double d = 5;
• int i = (int)d;
• short s = (short) i;
• float f = 10.67f;
• int x = (int) f;
4
www.infoviaan.com
Program - Type casting
public class TypeCasting{
public static void main(String args[]){
double d;
d=125.89;
int i=10;
int result =(int) d/i;
System.out.println("d : "+d);
System.out.println("d : "+ i);
System.out.println("result: "+result);
}
}
5
www.infoviaan.com
Program – Mix, Type Casting
public class MixingCharTypeCasting{
public static void main(String args[]){
char cv;
int iv1 = 64;
cv = (char) iv1;
System.out.println(“Character Value : ”+
cv);
System.out.println(“Integer Value : ”+ iv1);
}
}
6
www.infoviaan.com
Program – Mixing Number
public class MixingNumber{
public static void main(String args[]){
double fv1,fv2;
int iv1 =123;
fv1 = iv1/50;
fv2 = iv1/50.0;
System.out.println("fv1 : "+fv1);
System.out.println("fv2 : "+ fv2);
}
}
7
www.infoviaan.com
Parsing
• Parsing is used to convert the value of one data
type to a value of another data type
• Convert String (numeric) value to int, float,
double etc. then use Parsing
• String s = “678”;
• int i;
• i = Integer.parseInt(s);
• double d = Double.parseDouble(s);
• float f = Float.parseFloat(s);
• String ss = “true”;
• boolean b = Boolean.parseBoolean(ss); 8
www.infoviaan.com
Program - Parsing
public class Parsing{
public static void main(String args[]){
String s = “1999”;
int i = Integer.parseInt(s);
System.out.println(i + 10 );
}
}
9
www.infoviaan.com
Other data type to String
Animal
Human
• int i = 90;
• String s1 = String.valueOf(i);
• double d = 78.789;
• String s2 = String.valueOf(d);
• boolean b = true;
• String s3 = String.valueOf(b);
10
www.infoviaan.com
Operators
• An operator, is a special symbols performing specific
operations on one, two or three operands and then
returning a result.
or Increment/ Decrement
Other operator:
instanceof op. . (dot ) ; (terminator) , (comma) 11
www.infoviaan.com
12
www.infoviaan.com
Unary Operators
() Group operator
+ Unary Plus
- Unary Minus
~ Bitwise Complement
! Logical Negation
++ Pre – or Post-increment
-- Pre – or Post-decrement
13
www.infoviaan.com
Unary Operators
14
www.infoviaan.com
Program – Increment exercise
public class TestIncrement{
public static void main(String args[]){
int i = 0 ;
System.out.println( i++ + i++ + i++ + i++ + i++ +
i++);
System.out.println("Increment = "+ i++ + i++ + i++ +
i++ + i++ + i++);
System.out.println(i);
i = 0;
System.out.println(++i + ++i + ++i + ++i + ++i + ++i
);
System.out.println(i);
} 15
www.infoviaan.com
?
Binary Operators
a b
Operand Operand
Operator
16
www.infoviaan.com
Binary Operators
Additive & Multiplicative
+
-
*
/
%
Plus
Minus
Multiply
Divide
Remainder
= Assignment /Multiple Assignment
int a = 25;
int b = a = 30;
Assignment
+=
Compound Operator
-= *= /= %=
17
www.infoviaan.com
Concatenation (+)
• When + is used with after any string & (+ numbers)
then it is perform concatenation operation.
• And when + is used with int, float, double then it is
perform addition operation.
System.out.println(“Hello ”+ 20 +30); //Hello
2030
System.out.println(20+30); //50
System.out.println(20+30+” Hello”); //50
Hello
18
www.infoviaan.com
Program - Assignment
public class Assignment{
public static void main(String args[]){
int i1, i2, result;
result = (i1 = 1 ) + (i2 = 2);
System.out.println(“i1 = "+i1);
System.out.println(“i2 = "+ i2);
System.out.println(“result = "+
result);
}
}
19
www.infoviaan.com
Compound operator
• Compound operator provide convenient shorthand.
• Compound operators are :
+=
-=
/=
*=
%=
<<=
>>=
>>>=
Etc.
20
www.infoviaan.com
Relational/Conditional
Operators
<
==
Less than
Greater than
Less than or equal to
Is equal to
>
<=
>= Greater than or equal to
!= Not equal to
21
www.infoviaan.com
Logical Operators
&& Logical AND
Logical OR
Logical NOT!
||
22
www.infoviaan.com
Program - Logical AND
public class TestLogicalAnd{
public static void main(String args[]){
int i = 0;
System.out.println(“Test : "+ ((2<3) &&
(0< i++)));
System.out.println(" I = "+ i);
}
}
23
www.infoviaan.com
Program - Logical OR
System.out.println(“Test : "+ ((2<3) || (0<
i++)));
This never
gets
evaluated!
24
www.infoviaan.com
Program - Logical NOT
public class TestLogicalNot{
public static void main(String args[]){
boolean x = true;
System.out.println(" Test = "+ ( !x
));
}
}
25
www.infoviaan.com
Bitwise Operators
& <<Bitwise AND
Bitwise OR
Bitwise XOR
Left Shift
|
^
~ Bitwise NOT
>> Right Shift
>>> Unsigned Right Shift
26
www.infoviaan.com
Bitwise NOT (~)
----;
27
www.infoviaan.com
Bitwise AND
• When both condition are 1
then result is 1 otherwise
0.
----;
----;
28
www.infoviaan.com
Bitwise OR (|)
• When any one condition is 1
then result is 1 otherwise 0.----;
----;
29
www.infoviaan.com
Bitwise XOR(^)
• When both condition are same
then result is 0 otherwise 1.----;
----;
30
www.infoviaan.com
Bitwise Left Shift (<<)
----;
31
www.infoviaan.com
Bitwise Right Shift (>>)
----;
32
www.infoviaan.com
Bitwise Unsigned Right Shift
(>>>) ----;
33
www.infoviaan.com
Ternary/Conditional Operator
? : If “a” then “x” else
“y”
• Ternary operator consists of three operands and
is used to evaluate Boolean expressions.
• The goal of the operator is to decide, which
value should be assigned to the variable.
34
www.infoviaan.com
QA
1. What are the types of casting ?
2.What is Parsing ?
3.What is the difference between the Boolean &
operator and the && operator ?
4. What are Compound Assignment Operators ?
5.What is % operator ?
6.What is difference between byte, short, int and long
data types ?
7.What is difference between = and == operator ?
8.What is difference between pre increment and post
increment operator ?
9.True or False: - Pre-increment is faster than post-
increment ? 35
www.infoviaan.com
Get in Touch
Thank You
www.infoviaan.com
36
www.infoviaan.com
Ad

More Related Content

What's hot (20)

Python Basics
Python BasicsPython Basics
Python Basics
primeteacher32
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
Jussi Pohjolainen
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
Om Ganesh
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
Sunil OS
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Java &amp; advanced java
Java &amp; advanced javaJava &amp; advanced java
Java &amp; advanced java
BASAVARAJ HUNSHAL
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
Aakashdata
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
Aswin Krishnamoorthy
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
Roman Elizarov
 
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithClean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a Monolith
Victor Rentea
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
Rosario Renga
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
Logan Chien
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
Brett Meyer
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and Concurrency
Sunil OS
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJ
Sunil OS
 
Python Regular Expressions
Python Regular ExpressionsPython Regular Expressions
Python Regular Expressions
BMS Institute of Technology and Management
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
Martin McBride
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
Haitham El-Ghareeb
 
Java Input Output (java.io.*)
Java Input Output (java.io.*)Java Input Output (java.io.*)
Java Input Output (java.io.*)
Om Ganesh
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
Sunil OS
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)Introduction to the basics of Python programming (part 1)
Introduction to the basics of Python programming (part 1)
Pedro Rodrigues
 
Introduction to-python
Introduction to-pythonIntroduction to-python
Introduction to-python
Aakashdata
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
Roman Elizarov
 
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithClean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a Monolith
Victor Rentea
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
Rosario Renga
 
Java 8 lambda expressions
Java 8 lambda expressionsJava 8 lambda expressions
Java 8 lambda expressions
Logan Chien
 
ORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate OverviewORM, JPA, & Hibernate Overview
ORM, JPA, & Hibernate Overview
Brett Meyer
 
Java Threads and Concurrency
Java Threads and ConcurrencyJava Threads and Concurrency
Java Threads and Concurrency
Sunil OS
 
Java 8 - CJ
Java 8 - CJJava 8 - CJ
Java 8 - CJ
Sunil OS
 
Print input-presentation
Print input-presentationPrint input-presentation
Print input-presentation
Martin McBride
 

Similar to Type Casting Operator (20)

Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
walia Shaan
 
Java_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJava_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdf
JayveeCultivo
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
Sunil OS
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
mcollison
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
raksharao
 
Lyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingLyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarking
Pierre Laporte
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Chhom Karath
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
Soran University
 
Java Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionJava Unit Test and Coverage Introduction
Java Unit Test and Coverage Introduction
Alex Su
 
Introduction to c part -1
Introduction to c   part -1Introduction to c   part -1
Introduction to c part -1
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
henokmetaferia1
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first Security
Coverity
 
Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours? Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours?
Rogue Wave Software
 
Introduction to Java Programming Part 2
Introduction to Java Programming Part 2Introduction to Java Programming Part 2
Introduction to Java Programming Part 2
university of education,Lahore
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
Federico Tomassetti
 
report
reportreport
report
Quickoffice Test
 
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Tao Xie
 
C# 6.0 Preview
C# 6.0 PreviewC# 6.0 Preview
C# 6.0 Preview
Fujio Kojima
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
Intro C# Book
 
Nalinee java
Nalinee javaNalinee java
Nalinee java
Nalinee Choudhary
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
walia Shaan
 
Java_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdfJava_Programming_by_Example_6th_Edition.pdf
Java_Programming_by_Example_6th_Edition.pdf
JayveeCultivo
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
Sunil OS
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
mcollison
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
raksharao
 
Lyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingLyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarking
Pierre Laporte
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Chhom Karath
 
Java Unit Test and Coverage Introduction
Java Unit Test and Coverage IntroductionJava Unit Test and Coverage Introduction
Java Unit Test and Coverage Introduction
Alex Su
 
Chapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).pptChapter 2&3 (java fundamentals and Control Structures).ppt
Chapter 2&3 (java fundamentals and Control Structures).ppt
henokmetaferia1
 
DevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first SecurityDevBeat 2013 - Developer-first Security
DevBeat 2013 - Developer-first Security
Coverity
 
Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours? Static analysis works for mission-critical systems, why not yours?
Static analysis works for mission-critical systems, why not yours?
Rogue Wave Software
 
How do you create a programming language for the JVM?
How do you create a programming language for the JVM?How do you create a programming language for the JVM?
How do you create a programming language for the JVM?
Federico Tomassetti
 
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Transferring Software Testing Tools to Practice (AST 2017 Keynote)
Tao Xie
 
20.1 Java working with abstraction
20.1 Java working with abstraction20.1 Java working with abstraction
20.1 Java working with abstraction
Intro C# Book
 
Ad

Recently uploaded (20)

How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Ad

Type Casting Operator

  • 2. Small to big data type • Will be done automatically • int i = 5; • double d = i; • short s = 10; • int i = s; • long l = i; 2 www.infoviaan.com
  • 3. Program - Automatic Converting public class AutomaticConversion{ public static void main(String args[]){ int i = 89; float f = i / 2.5f; double d = f; System.out.println("integer : "+i); System.out.println("float : "+ f); System.out.println("double : "+ d); } } 3 www.infoviaan.com
  • 4. Big to Small data type When precision or data loss likely to happen then type casting is required. • double d = 5; • int i = (int)d; • short s = (short) i; • float f = 10.67f; • int x = (int) f; 4 www.infoviaan.com
  • 5. Program - Type casting public class TypeCasting{ public static void main(String args[]){ double d; d=125.89; int i=10; int result =(int) d/i; System.out.println("d : "+d); System.out.println("d : "+ i); System.out.println("result: "+result); } } 5 www.infoviaan.com
  • 6. Program – Mix, Type Casting public class MixingCharTypeCasting{ public static void main(String args[]){ char cv; int iv1 = 64; cv = (char) iv1; System.out.println(“Character Value : ”+ cv); System.out.println(“Integer Value : ”+ iv1); } } 6 www.infoviaan.com
  • 7. Program – Mixing Number public class MixingNumber{ public static void main(String args[]){ double fv1,fv2; int iv1 =123; fv1 = iv1/50; fv2 = iv1/50.0; System.out.println("fv1 : "+fv1); System.out.println("fv2 : "+ fv2); } } 7 www.infoviaan.com
  • 8. Parsing • Parsing is used to convert the value of one data type to a value of another data type • Convert String (numeric) value to int, float, double etc. then use Parsing • String s = “678”; • int i; • i = Integer.parseInt(s); • double d = Double.parseDouble(s); • float f = Float.parseFloat(s); • String ss = “true”; • boolean b = Boolean.parseBoolean(ss); 8 www.infoviaan.com
  • 9. Program - Parsing public class Parsing{ public static void main(String args[]){ String s = “1999”; int i = Integer.parseInt(s); System.out.println(i + 10 ); } } 9 www.infoviaan.com
  • 10. Other data type to String Animal Human • int i = 90; • String s1 = String.valueOf(i); • double d = 78.789; • String s2 = String.valueOf(d); • boolean b = true; • String s3 = String.valueOf(b); 10 www.infoviaan.com
  • 11. Operators • An operator, is a special symbols performing specific operations on one, two or three operands and then returning a result. or Increment/ Decrement Other operator: instanceof op. . (dot ) ; (terminator) , (comma) 11 www.infoviaan.com
  • 13. Unary Operators () Group operator + Unary Plus - Unary Minus ~ Bitwise Complement ! Logical Negation ++ Pre – or Post-increment -- Pre – or Post-decrement 13 www.infoviaan.com
  • 15. Program – Increment exercise public class TestIncrement{ public static void main(String args[]){ int i = 0 ; System.out.println( i++ + i++ + i++ + i++ + i++ + i++); System.out.println("Increment = "+ i++ + i++ + i++ + i++ + i++ + i++); System.out.println(i); i = 0; System.out.println(++i + ++i + ++i + ++i + ++i + ++i ); System.out.println(i); } 15 www.infoviaan.com
  • 16. ? Binary Operators a b Operand Operand Operator 16 www.infoviaan.com
  • 17. Binary Operators Additive & Multiplicative + - * / % Plus Minus Multiply Divide Remainder = Assignment /Multiple Assignment int a = 25; int b = a = 30; Assignment += Compound Operator -= *= /= %= 17 www.infoviaan.com
  • 18. Concatenation (+) • When + is used with after any string & (+ numbers) then it is perform concatenation operation. • And when + is used with int, float, double then it is perform addition operation. System.out.println(“Hello ”+ 20 +30); //Hello 2030 System.out.println(20+30); //50 System.out.println(20+30+” Hello”); //50 Hello 18 www.infoviaan.com
  • 19. Program - Assignment public class Assignment{ public static void main(String args[]){ int i1, i2, result; result = (i1 = 1 ) + (i2 = 2); System.out.println(“i1 = "+i1); System.out.println(“i2 = "+ i2); System.out.println(“result = "+ result); } } 19 www.infoviaan.com
  • 20. Compound operator • Compound operator provide convenient shorthand. • Compound operators are : += -= /= *= %= <<= >>= >>>= Etc. 20 www.infoviaan.com
  • 21. Relational/Conditional Operators < == Less than Greater than Less than or equal to Is equal to > <= >= Greater than or equal to != Not equal to 21 www.infoviaan.com
  • 22. Logical Operators && Logical AND Logical OR Logical NOT! || 22 www.infoviaan.com
  • 23. Program - Logical AND public class TestLogicalAnd{ public static void main(String args[]){ int i = 0; System.out.println(“Test : "+ ((2<3) && (0< i++))); System.out.println(" I = "+ i); } } 23 www.infoviaan.com
  • 24. Program - Logical OR System.out.println(“Test : "+ ((2<3) || (0< i++))); This never gets evaluated! 24 www.infoviaan.com
  • 25. Program - Logical NOT public class TestLogicalNot{ public static void main(String args[]){ boolean x = true; System.out.println(" Test = "+ ( !x )); } } 25 www.infoviaan.com
  • 26. Bitwise Operators & <<Bitwise AND Bitwise OR Bitwise XOR Left Shift | ^ ~ Bitwise NOT >> Right Shift >>> Unsigned Right Shift 26 www.infoviaan.com
  • 28. Bitwise AND • When both condition are 1 then result is 1 otherwise 0. ----; ----; 28 www.infoviaan.com
  • 29. Bitwise OR (|) • When any one condition is 1 then result is 1 otherwise 0.----; ----; 29 www.infoviaan.com
  • 30. Bitwise XOR(^) • When both condition are same then result is 0 otherwise 1.----; ----; 30 www.infoviaan.com
  • 31. Bitwise Left Shift (<<) ----; 31 www.infoviaan.com
  • 32. Bitwise Right Shift (>>) ----; 32 www.infoviaan.com
  • 33. Bitwise Unsigned Right Shift (>>>) ----; 33 www.infoviaan.com
  • 34. Ternary/Conditional Operator ? : If “a” then “x” else “y” • Ternary operator consists of three operands and is used to evaluate Boolean expressions. • The goal of the operator is to decide, which value should be assigned to the variable. 34 www.infoviaan.com
  • 35. QA 1. What are the types of casting ? 2.What is Parsing ? 3.What is the difference between the Boolean & operator and the && operator ? 4. What are Compound Assignment Operators ? 5.What is % operator ? 6.What is difference between byte, short, int and long data types ? 7.What is difference between = and == operator ? 8.What is difference between pre increment and post increment operator ? 9.True or False: - Pre-increment is faster than post- increment ? 35 www.infoviaan.com
  • 36. Get in Touch Thank You www.infoviaan.com 36 www.infoviaan.com