SlideShare a Scribd company logo
1 of 11
Download to read offline
Java Tokens: Keywords, Identifiers, Literals, Operators, and Seperators
A smallest individual unit in source code is known as Token
Java Tokens
Keywords Identifiers Literals Operators Seperators
Keywords are special tokens in the language which have reserved use in the language.
Keywords may not be used as identifiers in Java — you cannot declare a field whose name is a
keyword, for instance.
Java has 50 keywords among which 48 are in use but 2 (goto and const) are currently not in use
Here is a list of keywords in the Java programming language. You cannot use any of the
following as identifiers in your programs. The keywords const and goto are reserved, even
though they are not currently used. true, false, and null might seem like keywords, but they are
actually literals; you cannot use them as identifiers in your programs.
abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while
* not used
** added in
1.2
*** added in
1.4
**** added in
5.0
Identifiers are the names of variables, methods, classes, packages and interfaces.
• Don’t use a keyword
• Don’t use a space
• Don’t use a special symbol other than ( _ and $ )
• Cannot start with digit
• Any length
• If only a single word then use a lowercase
• If more than one word then start first word with lowercase and other words start with first
letter as Capital
For example:
int balance=500; //Single word
int bankBalance=500; //Multiple Words
• Use lowercase
For example:
package pack1;
package mypack1;
• Every word start with first letter as Capital
For example:
class Balance{}
class BankBalance{}
• Use Uppercase and Underscore for separating the words
For example:
int PI=3.14;
int MAX_VALUE=100;
Fixed value assigned to variables or used in expressions is known as Literals
• Integer Literals: for example: 1, -2, 8523, -2105 etc.
Data Type Size Range
byte 1 Byte -27 to 27 -1
short 2 Bytes -215 to 215 -1
int 4 Bytes -231 to 231 -1
long 8 Bytes -263 to 263 -1
• Floating Literals: for example: 1.02, -2.689, 8523.369, 2105 etc.
Data Type Size Range
float 4 Byte -3.4 * 1038 to 3.4 * 1038
double 8 Bytes -1.7 * 10308 to 1.7 * 10308
• Character Literals: for example: ‘A’, ‘B’, ‘@’, ‘&’ etc.
Data Type Size Range
char 2 Bytes All Unicode characters
• String Literals: for example: “Hello”, “Gurpreet Singh”, “ACET” etc.
Data Type Size Range
String 2 * No. of characters As much memory available
• Boolean Literals: true and false.
Data Type Size Range
boolean 1 Byte true or false
• Null Literals: null can be assigned to any reference type
Operators operates on operands. For example: In expression a+b , a & b are operands and +
is operator
• Arithmetic Operator: +, - , *, /, %. For example:
5+4 will result in 9 5-4 will result in 1 5*4 will result in 20 5/4 will result in 1
5%4 will result in 1 (remainder) -5%4 will result in -1 5%-4 will result in 1 -5%-4 will result in -1
Note: Sign of result in % operator depends on the sign of dividend(numerator)
• Relational Operator: <, >, <=, >=, ==, != Output will be either true or false
5>6 will result in false
5>=6 will result in false (either greater than or equal to)
5<6 will result in true
5<=6 will result in true (either less than or equal to)
5==6 will result in false (equal to)
5!=6 will result in true (not equal to)
• Assignment Operator: = Assign the value on left hand side to right hand side. For example:
A=10+5, will assign 15 to A
• Logical Operator: returns true or false
Logical AND (&&)
Logical OR (||)
Logical NOT (!)
A B A&&B A||B !A
true true true true false
true false false true false
false true false true true
false false false false true
• Increment/Decrement Operator: increases or decreases the value by 1
Pre-increment & Pre-decrement: ++a, --a
Post-increment & Post-decrement: a++, a--
• Bitwise Operator: Performs operations on bits
Bitwise AND(&)
Bitwise OR(|)
Bitwise XOR(^)
Bitwise Complement or Not (!)
A B A&B A|B A^B !A
0 0 0 0 1 1
0 1 0 1 0 1
1 0 0 1 0 0
1 1 1 1 1 0
• Shift Operator: shift the bits to left or right
Left Shift(<<): shifts the bits to left and fill the vacant spaces with 0
Unsigned Right Shift(>>>): shifts the bits to right and fill the vacant spaces with 0
Signed Right Shift(>>): shifts the bits to right and fill the vacant spaces with leftmost bit, i.e. if
leftmost bit is 0 then fill with 0, and if the leftmost bit is 1 then fill with 1
• Conditional(Ternary) Operator:
Syntax: condition(relational expression) ? Expression 1 : Expression 2
If condition evaluates to true then result will be Expression 1 otherwise Expression 2
{ } used to define block or to declare array with static elements
[ ] used to declare array variable
( ) used to define/call function or used in expressions
; used to terminate a statement
, used to separate variables in declaration
. used to access data members and member functions of an object or class

More Related Content

What's hot (19)

Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Core Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika TutorialsCore Java Tutorials by Mahika Tutorials
Core Java Tutorials by Mahika Tutorials
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Javatut1
Javatut1 Javatut1
Javatut1
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Core java
Core javaCore java
Core java
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Notes
Java Notes Java Notes
Java Notes
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...Introduction to Java programming - Java tutorial for beginners to teach Java ...
Introduction to Java programming - Java tutorial for beginners to teach Java ...
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
Ch01 basic-java-programs
Ch01 basic-java-programsCh01 basic-java-programs
Ch01 basic-java-programs
 
Core java
Core java Core java
Core java
 

Viewers also liked

Block diagram by vasant
Block diagram by vasantBlock diagram by vasant
Block diagram by vasantVasant Yeluri
 
Computer Structure Slides
Computer Structure SlidesComputer Structure Slides
Computer Structure Slidesiarthur
 
Block diagram of computer 02
Block diagram of computer 02Block diagram of computer 02
Block diagram of computer 02ZTE Nepal
 
Chapter 1 computer hardware and flow of information
Chapter 1 computer hardware and flow of informationChapter 1 computer hardware and flow of information
Chapter 1 computer hardware and flow of informationFrankie Jones
 
08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)Akhila Dakshina
 
Fundamentals Of Computer
Fundamentals Of ComputerFundamentals Of Computer
Fundamentals Of ComputerJack Frost
 
Computer hardware presentation
Computer hardware presentationComputer hardware presentation
Computer hardware presentationJisu Dasgupta
 
Block diagram of a computer
Block diagram of a computerBlock diagram of a computer
Block diagram of a computerQsrealm
 
Block diagram of a computer
Block diagram of a computerBlock diagram of a computer
Block diagram of a computerZTE Nepal
 
Computer hardware component. ppt
Computer hardware component. pptComputer hardware component. ppt
Computer hardware component. pptNaveen Sihag
 
basics of computer system ppt
basics of computer system pptbasics of computer system ppt
basics of computer system pptSuaj
 

Viewers also liked (11)

Block diagram by vasant
Block diagram by vasantBlock diagram by vasant
Block diagram by vasant
 
Computer Structure Slides
Computer Structure SlidesComputer Structure Slides
Computer Structure Slides
 
Block diagram of computer 02
Block diagram of computer 02Block diagram of computer 02
Block diagram of computer 02
 
Chapter 1 computer hardware and flow of information
Chapter 1 computer hardware and flow of informationChapter 1 computer hardware and flow of information
Chapter 1 computer hardware and flow of information
 
08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)08. Central Processing Unit (CPU)
08. Central Processing Unit (CPU)
 
Fundamentals Of Computer
Fundamentals Of ComputerFundamentals Of Computer
Fundamentals Of Computer
 
Computer hardware presentation
Computer hardware presentationComputer hardware presentation
Computer hardware presentation
 
Block diagram of a computer
Block diagram of a computerBlock diagram of a computer
Block diagram of a computer
 
Block diagram of a computer
Block diagram of a computerBlock diagram of a computer
Block diagram of a computer
 
Computer hardware component. ppt
Computer hardware component. pptComputer hardware component. ppt
Computer hardware component. ppt
 
basics of computer system ppt
basics of computer system pptbasics of computer system ppt
basics of computer system ppt
 

Similar to Java ppt2

IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialHassan A-j
 
python presentation.pptx
python presentation.pptxpython presentation.pptx
python presentation.pptxNightTune44
 
L3 operators
L3 operatorsL3 operators
L3 operatorsteach4uin
 
L3 operators
L3 operatorsL3 operators
L3 operatorsteach4uin
 
L3 operators
L3 operatorsL3 operators
L3 operatorsteach4uin
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variablesTony Apreku
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
4_A1208223655_21789_2_2018_04. Operators.ppt
4_A1208223655_21789_2_2018_04. Operators.ppt4_A1208223655_21789_2_2018_04. Operators.ppt
4_A1208223655_21789_2_2018_04. Operators.pptRithwikRanjan
 
C – A Programming Language- I
C – A Programming Language- IC – A Programming Language- I
C – A Programming Language- IGagan Deep
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
 

Similar to Java ppt2 (20)

unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
IOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorialIOS Swift Language 3rd tutorial
IOS Swift Language 3rd tutorial
 
python presentation.pptx
python presentation.pptxpython presentation.pptx
python presentation.pptx
 
L3 operators
L3 operatorsL3 operators
L3 operators
 
L3 operators
L3 operatorsL3 operators
L3 operators
 
L3 operators
L3 operatorsL3 operators
L3 operators
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Py-Slides-2 (1).ppt
Py-Slides-2 (1).pptPy-Slides-2 (1).ppt
Py-Slides-2 (1).ppt
 
Py-Slides-2.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
 
Py-Slides-2.ppt
Py-Slides-2.pptPy-Slides-2.ppt
Py-Slides-2.ppt
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
C++
C++ C++
C++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Python - Lecture 2
Python - Lecture 2Python - Lecture 2
Python - Lecture 2
 
4_A1208223655_21789_2_2018_04. Operators.ppt
4_A1208223655_21789_2_2018_04. Operators.ppt4_A1208223655_21789_2_2018_04. Operators.ppt
4_A1208223655_21789_2_2018_04. Operators.ppt
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
Python unit 1 (1).pptx
Python unit 1 (1).pptxPython unit 1 (1).pptx
Python unit 1 (1).pptx
 
C – A Programming Language- I
C – A Programming Language- IC – A Programming Language- I
C – A Programming Language- I
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 

More from nikhilsh66131

More from nikhilsh66131 (8)

Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Html beginners tutorial
Html beginners tutorialHtml beginners tutorial
Html beginners tutorial
 
Bubble and-merge-sort
Bubble and-merge-sortBubble and-merge-sort
Bubble and-merge-sort
 
Java ppt2
Java ppt2Java ppt2
Java ppt2
 
Java ppt1
Java ppt1Java ppt1
Java ppt1
 

Recently uploaded

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
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
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
 
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
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
“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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
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
 
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
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
“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...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

Java ppt2

  • 1. Java Tokens: Keywords, Identifiers, Literals, Operators, and Seperators
  • 2. A smallest individual unit in source code is known as Token Java Tokens Keywords Identifiers Literals Operators Seperators
  • 3. Keywords are special tokens in the language which have reserved use in the language. Keywords may not be used as identifiers in Java — you cannot declare a field whose name is a keyword, for instance. Java has 50 keywords among which 48 are in use but 2 (goto and const) are currently not in use Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs. abstract continue for new switch assert*** default goto* package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum**** instanceof return transient catch extends int short try char final interface static void class finally long strictfp** volatile const* float native super while * not used ** added in 1.2 *** added in 1.4 **** added in 5.0
  • 4. Identifiers are the names of variables, methods, classes, packages and interfaces. • Don’t use a keyword • Don’t use a space • Don’t use a special symbol other than ( _ and $ ) • Cannot start with digit • Any length • If only a single word then use a lowercase • If more than one word then start first word with lowercase and other words start with first letter as Capital For example: int balance=500; //Single word int bankBalance=500; //Multiple Words
  • 5. • Use lowercase For example: package pack1; package mypack1; • Every word start with first letter as Capital For example: class Balance{} class BankBalance{} • Use Uppercase and Underscore for separating the words For example: int PI=3.14; int MAX_VALUE=100;
  • 6. Fixed value assigned to variables or used in expressions is known as Literals • Integer Literals: for example: 1, -2, 8523, -2105 etc. Data Type Size Range byte 1 Byte -27 to 27 -1 short 2 Bytes -215 to 215 -1 int 4 Bytes -231 to 231 -1 long 8 Bytes -263 to 263 -1 • Floating Literals: for example: 1.02, -2.689, 8523.369, 2105 etc. Data Type Size Range float 4 Byte -3.4 * 1038 to 3.4 * 1038 double 8 Bytes -1.7 * 10308 to 1.7 * 10308
  • 7. • Character Literals: for example: ‘A’, ‘B’, ‘@’, ‘&’ etc. Data Type Size Range char 2 Bytes All Unicode characters • String Literals: for example: “Hello”, “Gurpreet Singh”, “ACET” etc. Data Type Size Range String 2 * No. of characters As much memory available • Boolean Literals: true and false. Data Type Size Range boolean 1 Byte true or false • Null Literals: null can be assigned to any reference type
  • 8. Operators operates on operands. For example: In expression a+b , a & b are operands and + is operator • Arithmetic Operator: +, - , *, /, %. For example: 5+4 will result in 9 5-4 will result in 1 5*4 will result in 20 5/4 will result in 1 5%4 will result in 1 (remainder) -5%4 will result in -1 5%-4 will result in 1 -5%-4 will result in -1 Note: Sign of result in % operator depends on the sign of dividend(numerator) • Relational Operator: <, >, <=, >=, ==, != Output will be either true or false 5>6 will result in false 5>=6 will result in false (either greater than or equal to) 5<6 will result in true 5<=6 will result in true (either less than or equal to) 5==6 will result in false (equal to) 5!=6 will result in true (not equal to)
  • 9. • Assignment Operator: = Assign the value on left hand side to right hand side. For example: A=10+5, will assign 15 to A • Logical Operator: returns true or false Logical AND (&&) Logical OR (||) Logical NOT (!) A B A&&B A||B !A true true true true false true false false true false false true false true true false false false false true • Increment/Decrement Operator: increases or decreases the value by 1 Pre-increment & Pre-decrement: ++a, --a Post-increment & Post-decrement: a++, a--
  • 10. • Bitwise Operator: Performs operations on bits Bitwise AND(&) Bitwise OR(|) Bitwise XOR(^) Bitwise Complement or Not (!) A B A&B A|B A^B !A 0 0 0 0 1 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 1 1 1 0 • Shift Operator: shift the bits to left or right Left Shift(<<): shifts the bits to left and fill the vacant spaces with 0 Unsigned Right Shift(>>>): shifts the bits to right and fill the vacant spaces with 0 Signed Right Shift(>>): shifts the bits to right and fill the vacant spaces with leftmost bit, i.e. if leftmost bit is 0 then fill with 0, and if the leftmost bit is 1 then fill with 1 • Conditional(Ternary) Operator: Syntax: condition(relational expression) ? Expression 1 : Expression 2 If condition evaluates to true then result will be Expression 1 otherwise Expression 2
  • 11. { } used to define block or to declare array with static elements [ ] used to declare array variable ( ) used to define/call function or used in expressions ; used to terminate a statement , used to separate variables in declaration . used to access data members and member functions of an object or class