SlideShare a Scribd company logo
1 of 21
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
 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)

Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
classes and objects in C++
classes and objects in C++classes and objects in C++
classes and objects in C++
 
Java program structure
Java program structureJava program structure
Java program structure
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
JVM
JVMJVM
JVM
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Java swing
Java swingJava swing
Java swing
 
Java(Polymorphism)
Java(Polymorphism)Java(Polymorphism)
Java(Polymorphism)
 
11. java methods
11. java methods11. java methods
11. java methods
 
Java literals
Java literalsJava literals
Java literals
 
Java threads
Java threadsJava threads
Java threads
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
History of java'
History of java'History of java'
History of java'
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 

Similar to Java Tokens

Overview of java Language-3.pdf
Overview of java Language-3.pdfOverview of java Language-3.pdf
Overview of java Language-3.pdfkumari36
 
Java Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsAkshaj Vadakkath Joshy
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering4MU21CS023
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1SURBHI SAROHA
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java MayaTofik
 
Introduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologiesIntroduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologiesTabassumMaktum
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with javaTechglyphs
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for MainframersRich Helton
 
java handout.doc
java handout.docjava handout.doc
java handout.docSOMOSCO1
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocksİbrahim Kürce
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to JavaDevaKumari Vijay
 

Similar to Java Tokens (20)

Overview of java Language-3.pdf
Overview of java Language-3.pdfOverview of java Language-3.pdf
Overview of java Language-3.pdf
 
Java Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming Basics
 
Concepts of core java
Concepts of core javaConcepts of core java
Concepts of core java
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
 
OOP Poster Presentation
OOP Poster PresentationOOP Poster Presentation
OOP Poster Presentation
 
Java_Roadmap.pptx
Java_Roadmap.pptxJava_Roadmap.pptx
Java_Roadmap.pptx
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
Introduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologiesIntroduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologies
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Java unit 2
Java unit 2Java unit 2
Java unit 2
 
java handout.doc
java handout.docjava handout.doc
java handout.doc
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Java tokens
Java tokensJava tokens
Java tokens
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 

More from Madishetty Prathibha

More from Madishetty Prathibha (14)

Object Oriented programming - Introduction
Object Oriented programming - IntroductionObject Oriented programming - Introduction
Object Oriented programming - Introduction
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Structure of java program diff c- cpp and java
Structure of java program  diff c- cpp and javaStructure of java program  diff c- cpp and java
Structure of java program diff c- cpp and java
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Types of datastructures
Types of datastructuresTypes of datastructures
Types of datastructures
 
Introduction to algorithms
Introduction to algorithmsIntroduction to algorithms
Introduction to algorithms
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 
Introduction to data structures (ss)
Introduction to data structures (ss)Introduction to data structures (ss)
Introduction to data structures (ss)
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
Java features
Java  features Java  features
Java features
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 

Recently uploaded

Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 

Recently uploaded (20)

FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 

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.
  • 6.
  • 7.
  • 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