SlideShare a Scribd company logo
10
Most read
13
Most read
14
Most read
JAVA
Prepared by
P.Prathibha
Lecturer
Topics for Today’s Session
Object Oriented Programming
JAVA TOKENS
COMMENTS
keywords Constants
Operators Separators
Identifiers
Initially developed
by
James Gosling
at
Sun Microsystems
and
released
in
1995.
JAVA
Object Oriented Programming
 Object oriented Programming is a modern programming method
to design a program using Classes and Objects
Objects
Real world entities that has their own
properties and behaviours such as
Book, Chair, Car, Pen, Table, etc.,
Class
A class is a blueprint or prototype from
which objects are created.
 Major objective is to eliminate unfavorable features
encountered in Procedural approach
What is
Java? Java is a computing platform for application development
and an object-oriented,
 Java is Class-based and Concurrent programming
language
 It means the code can be executed by multiple processes at
the same time.
 Java can run on all platforms and free to access.
 Java is Simple, Secure, Robust, Complete Object oriented
and Platform Independent High level Language
 It is Portable and Multi-thread technology gives High
Performance.
Java  Tokens
Java  Tokens
Java Tokens
 A Java Program
 contains number of classes
 Classes contains number of statements and methods
 Methods contains various expressions and statements.
which describes the actions carried out on data.
 Smallest individual units in a program are called
“Tokens”
 Token is basically smallest element, which is identified
by the Compiler.
 Java compiler uses tokens for constructing expressions
and statements.
Keywords
Identifier
Constants
Operators
Separators
Types of Tokens
Java Tokens are classified into
Keywords
 Keywords are essential part of a language definition.
 These are pre-defined or Reserved words in a
programming language.
 Keywords are standard identifiers and their functions is
predefined by the Compiler.
 Each keyword is assigned a special task cannot be
changed by the user.
 These cannot be used as identifiers.
 These are, a part of Java syntax .
 A keyword should always be written in lowercase as Java
is a case sensitive language.
 Java has reserved 50 words as Keywords.
List of Java Keywords
Java Identifiers
 Identifiers are Programmer designed tokens.
 These are used for identification purposes.
 Identifiers are the names, which are assigned to classes,
Objects, Labels, Variables, Methods, Packages and
Interfaces.
For Example: words which are in red are identifiers like
int num=2;
String str=“Hello”;
Class Fruit ( /* class members*/
Void function() {/* method body */
int sum() {/* method body*/
Points To Remember Regarding
Identifiers
1. We can use uppercase letters (A to Z), lowercase letters ( a to b),
dollar symbol ($), numerals (0 to 9) and underscore (_) only
while creating an Identifier.
2. Identifiers must begin with a letter, dollar sign or underscore.
But not with numbers.
3. Identifiers cannot be a keyword.
4. Identifiers are case-sensitive.
5. It's a convention to start an identifier with a letter rather
and $ or _.
6. After the first character, Identifier can have any combination of
characters
7. Whitespaces are not allowed.
8. Similarly, you cannot use symbols such as @, #, and so on.
Example: (Valid identifiers) : $xy, _name,ab12
Example: (Invalid identifiers) : *a,-h4,12num,%sd, float
Constants/ Literals
 Constants are also like normal variables. But their values can not be
modified by the program once they are defined.
 Constants refers to fixed values. They are also called as literals.
 Any constant value which can be assigned to the variable is called as
literal/constant.
 Constants are expressions with a immutable value.
 These are defined by users and can belong to any data type.
 Java supports five types of literals which are as follows:
1. Integer
2. Floating Point
3. Character
4. String
5. Boolean
Example: int a1 = 782; // Int literal
float c2 = 451.40; // Float literal
char c = “Hello” // char literal
String name = “Harsha"; // String literal
boolean x = true; // Boolean literal
Operators
 An operator is a symbol that represents a mathematical or
non- mathematical operation.
 Operators are used to perform operations on variables
and values.
 Java divides the operators into the following :
1. Arithmetic operators
2. Assignment operators
3. Relational / Comparison operators
4. Logical operators
5. Unary Operators ( Increment , Decrement Operators)
6. Bitwise operators
7. Conditional Operators
8. Special Operators
 Separator is a token used to separate two individual tokens used in a Java
program.
 These are Special symbols used to indicate where a groups of code are divided
and arranged.
 These are few characters which have special meaning known to Java
compiler and cannot be used for any other purpose.
 Separators are also known as Punctuators
Separators
Symbol Description
Brackets []
These are used as an array element reference and also indicates single
and multidimensional subscripts
Parentheses() These indicate a function call along with function parameters
Braces{}
Define the beginning and end of a block of code for Classes, Methods
and local scopes
Comma ( , )
To separate variable declarations, also helps in separating more than one
statement in an expression
Semi-Colon (;)
This is used to invoke an initialization list and also to separate
statements
Asterisk (*) This is used to create a pointer variable in Java
Period(.)
To separate package names from sub packages and classes and also
used to separate a variable or method from a reference variable.
Comments
 Comments in Java are often are non-executable statements,
used to understand the code better.
 Comments make the program more readable.
 Comments are ignored by the compiler while compiling a code.
 Comments are the statements that are not executed by the
compiler and interpreter.
 The comments can be used to provide information or
explanation about the variable, method, class or any statement.
Types of Java Comments: There are three types of comments :
1. Single Line Comment
2. Multi Line Comment
3. Documentation Comment
1. Single-line comments:
 This type of comment is mainly used for describing the code
functionality.
 These used to comment only one line.
 These start with two forward slashes (//).
 Any text between // and the end of the line is ignored by Java (will
not be executed).
//This is single line comment
2. Multi Line Comment
 The multi line comment is used to comment multiple lines of
code.
 Multi-line comments start with /* and ends with */.
 Any text between /* and */ will be ignored by Java.
/*
This is multi line
comment
*/
3. Documentation Comment
 This type of comments is used generally when you are writing
code for a project/ software package.
 The documentation comment is used to create documentation
API.
 To create documentation API, you need to use javadoc tool.
/**
This is
documentation
comment
*/
Conclusion
 In this lesson you learnt about
 Object Oriented Programming
 What is Java?
 Java Tokens
 Comments
Java  Tokens

More Related Content

What's hot (20)

PPTX
Inheritance in java
RahulAnanda1
 
PPTX
File handling
priya_trehan
 
PPTX
Packages in java
Elizabeth alexander
 
PPTX
Constructor in java
Pavith Gunasekara
 
PDF
Applets
Prabhakaran V M
 
PPTX
Basics of JAVA programming
Elizabeth Thomas
 
PPTX
Java package
CS_GDRCST
 
PPTX
Constructor and Types of Constructors
Dhrumil Panchal
 
PPS
Java Exception handling
kamal kotecha
 
PPT
Java buzzwords
ramesh517
 
PPTX
Classes, objects in JAVA
Abhilash Nair
 
PPT
Exception Handling in JAVA
SURIT DATTA
 
PPT
Class and object in C++
rprajat007
 
PPTX
Java Data Types
Spotle.ai
 
PPTX
Java program structure
Mukund Kumar Bharti
 
PPTX
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
PPTX
Event Handling in java
Google
 
PPTX
Data types
Nokesh Prabhakar
 
PPTX
History of java'
deepthisujithra
 
Inheritance in java
RahulAnanda1
 
File handling
priya_trehan
 
Packages in java
Elizabeth alexander
 
Constructor in java
Pavith Gunasekara
 
Basics of JAVA programming
Elizabeth Thomas
 
Java package
CS_GDRCST
 
Constructor and Types of Constructors
Dhrumil Panchal
 
Java Exception handling
kamal kotecha
 
Java buzzwords
ramesh517
 
Classes, objects in JAVA
Abhilash Nair
 
Exception Handling in JAVA
SURIT DATTA
 
Class and object in C++
rprajat007
 
Java Data Types
Spotle.ai
 
Java program structure
Mukund Kumar Bharti
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Event Handling in java
Google
 
Data types
Nokesh Prabhakar
 
History of java'
deepthisujithra
 

Similar to Java Tokens (20)

PDF
Overview of java Language-3.pdf
kumari36
 
PPTX
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
gkgupta1115
 
PPTX
JAVA PROGRAMMING
satyanarayanamurthy mangipudi
 
PPTX
JAVA programming language made easy.pptx
Sunila31
 
PPTX
Lec 1.3 Object Oriented Programming
Badar Waseer
 
PPTX
Programming in java basics
LovelitJose
 
PDF
ITFT - Java
Blossom Sood
 
PPTX
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
rishiskj
 
PDF
ch02-Java Fundamentals-Java Fundamentals.pdf
ayeshazaveri4
 
PPTX
Java tokens
shalinikarunakaran1
 
PPTX
Chapter 2
siragezeynu
 
PPTX
Java Programming
RubaNagarajan
 
PPTX
Java Tokens in java program . pptx
CmDept
 
PPTX
Java fundamentals
Jayfee Ramos
 
PPTX
OOP Introduction Part 2 In Java Language.pptx
habibansar098
 
PPT
Java Basics
Brandon Black
 
PPTX
Java Basic Elements Lecture on Computer Science
AnezkaJaved
 
PPT
Java_Identifiers_keywords_data_types.ppt
JyothiAmpally
 
PPT
java tutorial for beginners learning.ppt
usha852
 
PPTX
Class 8 - Java.pptx
sreedevi143432
 
Overview of java Language-3.pdf
kumari36
 
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
gkgupta1115
 
JAVA programming language made easy.pptx
Sunila31
 
Lec 1.3 Object Oriented Programming
Badar Waseer
 
Programming in java basics
LovelitJose
 
ITFT - Java
Blossom Sood
 
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
rishiskj
 
ch02-Java Fundamentals-Java Fundamentals.pdf
ayeshazaveri4
 
Java tokens
shalinikarunakaran1
 
Chapter 2
siragezeynu
 
Java Programming
RubaNagarajan
 
Java Tokens in java program . pptx
CmDept
 
Java fundamentals
Jayfee Ramos
 
OOP Introduction Part 2 In Java Language.pptx
habibansar098
 
Java Basics
Brandon Black
 
Java Basic Elements Lecture on Computer Science
AnezkaJaved
 
Java_Identifiers_keywords_data_types.ppt
JyothiAmpally
 
java tutorial for beginners learning.ppt
usha852
 
Class 8 - Java.pptx
sreedevi143432
 
Ad

More from Madishetty Prathibha (13)

PPTX
Object Oriented programming - Introduction
Madishetty Prathibha
 
PPTX
Access modifiers in java
Madishetty Prathibha
 
PPTX
Constructor in java
Madishetty Prathibha
 
PPTX
Control statements in java
Madishetty Prathibha
 
PPTX
Classes objects in java
Madishetty Prathibha
 
PPTX
Structure of java program diff c- cpp and java
Madishetty Prathibha
 
PPTX
Operators in java
Madishetty Prathibha
 
PPTX
Types of datastructures
Madishetty Prathibha
 
PPTX
Introduction to algorithms
Madishetty Prathibha
 
PPTX
Introduction to data structures (ss)
Madishetty Prathibha
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPT
Java features
Madishetty Prathibha
 
PPSX
Introduction of java
Madishetty Prathibha
 
Object Oriented programming - Introduction
Madishetty Prathibha
 
Access modifiers in java
Madishetty Prathibha
 
Constructor in java
Madishetty Prathibha
 
Control statements in java
Madishetty Prathibha
 
Classes objects in java
Madishetty Prathibha
 
Structure of java program diff c- cpp and java
Madishetty Prathibha
 
Operators in java
Madishetty Prathibha
 
Types of datastructures
Madishetty Prathibha
 
Introduction to algorithms
Madishetty Prathibha
 
Introduction to data structures (ss)
Madishetty Prathibha
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Java features
Madishetty Prathibha
 
Introduction of java
Madishetty Prathibha
 
Ad

Recently uploaded (20)

PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPT
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
PPTX
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
PPTX
Introduction to Probability(basic) .pptx
purohitanuj034
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PPTX
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
Basics and rules of probability with real-life uses
ravatkaran694
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
K-Circle-Weekly-Quiz12121212-May2025.pptx
Pankaj Rodey
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
Introduction to Probability(basic) .pptx
purohitanuj034
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 

Java Tokens

  • 2. Topics for Today’s Session Object Oriented Programming JAVA TOKENS COMMENTS keywords Constants Operators Separators Identifiers
  • 3. Initially developed by James Gosling at Sun Microsystems and released in 1995. JAVA
  • 4. Object Oriented Programming  Object oriented Programming is a modern programming method to design a program using Classes and Objects Objects Real world entities that has their own properties and behaviours such as Book, Chair, Car, Pen, Table, etc., Class A class is a blueprint or prototype from which objects are created.  Major objective is to eliminate unfavorable features encountered in Procedural approach
  • 5. What is Java? Java is a computing platform for application development and an object-oriented,  Java is Class-based and Concurrent programming language  It means the code can be executed by multiple processes at the same time.  Java can run on all platforms and free to access.  Java is Simple, Secure, Robust, Complete Object oriented and Platform Independent High level Language  It is Portable and Multi-thread technology gives High Performance.
  • 8. Java Tokens  A Java Program  contains number of classes  Classes contains number of statements and methods  Methods contains various expressions and statements. which describes the actions carried out on data.  Smallest individual units in a program are called “Tokens”  Token is basically smallest element, which is identified by the Compiler.  Java compiler uses tokens for constructing expressions and statements.
  • 10. Keywords  Keywords are essential part of a language definition.  These are pre-defined or Reserved words in a programming language.  Keywords are standard identifiers and their functions is predefined by the Compiler.  Each keyword is assigned a special task cannot be changed by the user.  These cannot be used as identifiers.  These are, a part of Java syntax .  A keyword should always be written in lowercase as Java is a case sensitive language.  Java has reserved 50 words as Keywords.
  • 11. List of Java Keywords
  • 12. Java Identifiers  Identifiers are Programmer designed tokens.  These are used for identification purposes.  Identifiers are the names, which are assigned to classes, Objects, Labels, Variables, Methods, Packages and Interfaces. For Example: words which are in red are identifiers like int num=2; String str=“Hello”; Class Fruit ( /* class members*/ Void function() {/* method body */ int sum() {/* method body*/
  • 13. Points To Remember Regarding Identifiers 1. We can use uppercase letters (A to Z), lowercase letters ( a to b), dollar symbol ($), numerals (0 to 9) and underscore (_) only while creating an Identifier. 2. Identifiers must begin with a letter, dollar sign or underscore. But not with numbers. 3. Identifiers cannot be a keyword. 4. Identifiers are case-sensitive. 5. It's a convention to start an identifier with a letter rather and $ or _. 6. After the first character, Identifier can have any combination of characters 7. Whitespaces are not allowed. 8. Similarly, you cannot use symbols such as @, #, and so on. Example: (Valid identifiers) : $xy, _name,ab12 Example: (Invalid identifiers) : *a,-h4,12num,%sd, float
  • 14. Constants/ Literals  Constants are also like normal variables. But their values can not be modified by the program once they are defined.  Constants refers to fixed values. They are also called as literals.  Any constant value which can be assigned to the variable is called as literal/constant.  Constants are expressions with a immutable value.  These are defined by users and can belong to any data type.  Java supports five types of literals which are as follows: 1. Integer 2. Floating Point 3. Character 4. String 5. Boolean Example: int a1 = 782; // Int literal float c2 = 451.40; // Float literal char c = “Hello” // char literal String name = “Harsha"; // String literal boolean x = true; // Boolean literal
  • 15. Operators  An operator is a symbol that represents a mathematical or non- mathematical operation.  Operators are used to perform operations on variables and values.  Java divides the operators into the following : 1. Arithmetic operators 2. Assignment operators 3. Relational / Comparison operators 4. Logical operators 5. Unary Operators ( Increment , Decrement Operators) 6. Bitwise operators 7. Conditional Operators 8. Special Operators
  • 16.  Separator is a token used to separate two individual tokens used in a Java program.  These are Special symbols used to indicate where a groups of code are divided and arranged.  These are few characters which have special meaning known to Java compiler and cannot be used for any other purpose.  Separators are also known as Punctuators Separators Symbol Description Brackets [] These are used as an array element reference and also indicates single and multidimensional subscripts Parentheses() These indicate a function call along with function parameters Braces{} Define the beginning and end of a block of code for Classes, Methods and local scopes Comma ( , ) To separate variable declarations, also helps in separating more than one statement in an expression Semi-Colon (;) This is used to invoke an initialization list and also to separate statements Asterisk (*) This is used to create a pointer variable in Java Period(.) To separate package names from sub packages and classes and also used to separate a variable or method from a reference variable.
  • 17. Comments  Comments in Java are often are non-executable statements, used to understand the code better.  Comments make the program more readable.  Comments are ignored by the compiler while compiling a code.  Comments are the statements that are not executed by the compiler and interpreter.  The comments can be used to provide information or explanation about the variable, method, class or any statement. Types of Java Comments: There are three types of comments : 1. Single Line Comment 2. Multi Line Comment 3. Documentation Comment
  • 18. 1. Single-line comments:  This type of comment is mainly used for describing the code functionality.  These used to comment only one line.  These start with two forward slashes (//).  Any text between // and the end of the line is ignored by Java (will not be executed). //This is single line comment 2. Multi Line Comment  The multi line comment is used to comment multiple lines of code.  Multi-line comments start with /* and ends with */.  Any text between /* and */ will be ignored by Java. /* This is multi line comment */
  • 19. 3. Documentation Comment  This type of comments is used generally when you are writing code for a project/ software package.  The documentation comment is used to create documentation API.  To create documentation API, you need to use javadoc tool. /** This is documentation comment */
  • 20. Conclusion  In this lesson you learnt about  Object Oriented Programming  What is Java?  Java Tokens  Comments