SlideShare a Scribd company logo
Data Types
Data Type Size Range
byte 1 byte -128 to 127
short 2 bytes -32768 to 32767
int 4 bytes -2,147,483,648 to 2,147,483,647
long 8 bytes -9,223,372,036,854,775,808 to-
9,223,372,036,854,775,807
float 4 bytes Approx. ± 3.4028235E+38F
double 8 bytes Approx. ± 1.7976931348623157E+308
boolean true or false NA, note Java booleans cannot be converted to or
from other types
char 2 bytes Unicode character,
u0000 (or 0) to uFFFF (or 65535)
Prepared By VijayaAhire (Asst Prof )
Type conversion (Casting)
Java automatically converts the source type into target type
This is known as automatic type conversion
For ex.:
float a = 10.6f;
int b;
b = a; //output 10
Type casting refers to the type conversion that is performed explicitly
For Ex.:
int x;
byte n = (byte)x;
long m = (long)x;
Prepared By VijayaAhire (Asst Prof )
long
64 bit
int
32 bit
l
i
int i;
i = (int)l;
l = (long)i;
long l;
l = i;
long
64 bit
int
32 bit
l
i
Widening
Narrowing
Casting example
Prepared By VijayaAhire (Asst Prof )
Operators
• An operator is a symbol that operates on one or more operands to produce
a result
• Java provides rich sets of operators
Operator Name Operators
Arithmetic Operator +, -, *, /, %
Relational Operator >, >=, <, <=, ==, !=
Logical Operator &&, ||, !
Assignment Operator = (+=, -=, *=, /=, %=)
Increment and decrement
Operator
++, --
Prefix (++a), postfix (a++)
Conditional Operator ? : (exp1 ? exp2 : exp3)
Bitwise Operator ~, &, |, ^, >>, <<, >>>
Special Operator instanceof .(dot) ,(comma)
Prepared By VijayaAhire (Asst Prof )
Expression
Expression are the combination of operands and operators
The order of operations is defined through precedence
For Ex.:
x = 10 + 2 * 6
= 10 + 12
= 22
Prepared By VijayaAhire (Asst Prof )
Operators in JAVA
• Arithmetic operators
• + addition
• - subtraction
• * multiplication
• / division
• % modulus (gives
reminder)
02-09-2022 7
class Arithmetic
{
public static void main(String[] args)
{
int a = 12 ;
int b = 3 ;
int c = a + b ;
System.out.println("Value of a + b = "+ c);
int d = a - b;
System.out.println("Value of a - b = "+ d);
int e = a * b;
System.out.println("Value of a * b = "+ e);
int f = a / b;
System.out.println("Value of a / b = "+ f);
int g = a % b;
System.out.println("Value of a % b = "+ g);
}
}
C = 15
d = 9
e = 36
f = 4
g = 0
Operators in JAVA
• Assignment operators
02-09-2022 8
class Arithmetic
{
public static void main(String[] args)
{
int x =4;
x*=3;
System.out.println("Value of x = "+ x);
}
}
= x = 2 x = 2
+= x += 4 x = x + 4
-= x -= 4 x = x - 4
*= x *= 4 x = x * 4
/= x /= 4 x = x / 4
%= x %= 4 x = x % 4
X=12
Operators in JAVA
• Relational operators
02-09-2022 9
Operator Description
== Check if two operand are equal
!= Check if two operand are not equal.
>
Check if operand on the left is
greater than operand on the right
<
Check operand on the left is smaller
than right operand
>=
check left operand is greater than or
equal to right operand
<=
Check if operand on left is smaller
than or equal to right operand
Operator Description
&&
Returns true if both statements
are true
||
Returns true if one of the
statements is true
!
Reverse the result, returns
false if the result is true
• Logical operators
Operators in JAVA
• Bitwise operators
02-09-2022 10
Operator Description
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
<< Left shift
>> Right shift
Lect-3 Java VKA.pptx

More Related Content

Similar to Lect-3 Java VKA.pptx

Nalinee java
Nalinee javaNalinee java
Nalinee java
Nalinee Choudhary
 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
Divyanshu Dubey
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogramprincepavan
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogramprincepavan
 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdf
Aditya Kumar
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
rajatryadav22
 
arrays
arraysarrays
arrays
teach4uin
 
java programming cheatsheet
java programming cheatsheetjava programming cheatsheet
java programming cheatsheet
BD AB
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsHCMUTE
 
Java operators
Java operatorsJava operators
Java operators
Shehrevar Davierwala
 
Syntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - MindbowserSyntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - Mindbowser
Mindbowser Inc
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
Vedant Gavhane
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
YashwanthCse
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
ssuserd6b1fd
 
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
GkhanGirgin3
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
Dipta Saha
 
Java Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type ConversionJava Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type Conversion
Svetlin Nakov
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
Emertxe Information Technologies Pvt Ltd
 

Similar to Lect-3 Java VKA.pptx (20)

Nalinee java
Nalinee javaNalinee java
Nalinee java
 
C++ tutorials
C++ tutorialsC++ tutorials
C++ tutorials
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
 
T02 a firstcprogram
T02 a firstcprogramT02 a firstcprogram
T02 a firstcprogram
 
Java Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdfJava Question-Bank-Class-8.pdf
Java Question-Bank-Class-8.pdf
 
The best every notes on c language is here check it out
The best every notes on c language is here check it outThe best every notes on c language is here check it out
The best every notes on c language is here check it out
 
L7 pointers
L7 pointersL7 pointers
L7 pointers
 
arrays
arraysarrays
arrays
 
java programming cheatsheet
java programming cheatsheetjava programming cheatsheet
java programming cheatsheet
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Java operators
Java operatorsJava operators
Java operators
 
Syntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - MindbowserSyntax Comparison of Golang with C and Java - Mindbowser
Syntax Comparison of Golang with C and Java - Mindbowser
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
 
cuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdfcuptopointer-180804092048-190306091149 (2).pdf
cuptopointer-180804092048-190306091149 (2).pdf
 
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
Notes for C Programming for MCA, BCA, B. Tech CSE, ECE and MSC (CS) 4 of 5 by...
 
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
booksoncprogramminglanguage-anintroductiontobeginnersbyarunumrao4-21101016591...
 
Programming in C Presentation upto FILE
Programming in C Presentation upto FILEProgramming in C Presentation upto FILE
Programming in C Presentation upto FILE
 
Java Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type ConversionJava Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type Conversion
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 

Recently uploaded

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
Kamal Acharya
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
VishalDeshpande27
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
Emre Günaydın
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
gettygaming1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 

Recently uploaded (20)

HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 
shape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptxshape functions of 1D and 2 D rectangular elements.pptx
shape functions of 1D and 2 D rectangular elements.pptx
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 

Lect-3 Java VKA.pptx

  • 1.
  • 2. Data Types Data Type Size Range byte 1 byte -128 to 127 short 2 bytes -32768 to 32767 int 4 bytes -2,147,483,648 to 2,147,483,647 long 8 bytes -9,223,372,036,854,775,808 to- 9,223,372,036,854,775,807 float 4 bytes Approx. ± 3.4028235E+38F double 8 bytes Approx. ± 1.7976931348623157E+308 boolean true or false NA, note Java booleans cannot be converted to or from other types char 2 bytes Unicode character, u0000 (or 0) to uFFFF (or 65535) Prepared By VijayaAhire (Asst Prof )
  • 3. Type conversion (Casting) Java automatically converts the source type into target type This is known as automatic type conversion For ex.: float a = 10.6f; int b; b = a; //output 10 Type casting refers to the type conversion that is performed explicitly For Ex.: int x; byte n = (byte)x; long m = (long)x; Prepared By VijayaAhire (Asst Prof )
  • 4. long 64 bit int 32 bit l i int i; i = (int)l; l = (long)i; long l; l = i; long 64 bit int 32 bit l i Widening Narrowing Casting example Prepared By VijayaAhire (Asst Prof )
  • 5. Operators • An operator is a symbol that operates on one or more operands to produce a result • Java provides rich sets of operators Operator Name Operators Arithmetic Operator +, -, *, /, % Relational Operator >, >=, <, <=, ==, != Logical Operator &&, ||, ! Assignment Operator = (+=, -=, *=, /=, %=) Increment and decrement Operator ++, -- Prefix (++a), postfix (a++) Conditional Operator ? : (exp1 ? exp2 : exp3) Bitwise Operator ~, &, |, ^, >>, <<, >>> Special Operator instanceof .(dot) ,(comma) Prepared By VijayaAhire (Asst Prof )
  • 6. Expression Expression are the combination of operands and operators The order of operations is defined through precedence For Ex.: x = 10 + 2 * 6 = 10 + 12 = 22 Prepared By VijayaAhire (Asst Prof )
  • 7. Operators in JAVA • Arithmetic operators • + addition • - subtraction • * multiplication • / division • % modulus (gives reminder) 02-09-2022 7 class Arithmetic { public static void main(String[] args) { int a = 12 ; int b = 3 ; int c = a + b ; System.out.println("Value of a + b = "+ c); int d = a - b; System.out.println("Value of a - b = "+ d); int e = a * b; System.out.println("Value of a * b = "+ e); int f = a / b; System.out.println("Value of a / b = "+ f); int g = a % b; System.out.println("Value of a % b = "+ g); } } C = 15 d = 9 e = 36 f = 4 g = 0
  • 8. Operators in JAVA • Assignment operators 02-09-2022 8 class Arithmetic { public static void main(String[] args) { int x =4; x*=3; System.out.println("Value of x = "+ x); } } = x = 2 x = 2 += x += 4 x = x + 4 -= x -= 4 x = x - 4 *= x *= 4 x = x * 4 /= x /= 4 x = x / 4 %= x %= 4 x = x % 4 X=12
  • 9. Operators in JAVA • Relational operators 02-09-2022 9 Operator Description == Check if two operand are equal != Check if two operand are not equal. > Check if operand on the left is greater than operand on the right < Check operand on the left is smaller than right operand >= check left operand is greater than or equal to right operand <= Check if operand on left is smaller than or equal to right operand Operator Description && Returns true if both statements are true || Returns true if one of the statements is true ! Reverse the result, returns false if the result is true • Logical operators
  • 10. Operators in JAVA • Bitwise operators 02-09-2022 10 Operator Description & Bitwise AND | Bitwise OR ^ Bitwise exclusive OR << Left shift >> Right shift