SlideShare a Scribd company logo
1 of 15
Download to read offline
Java Class 
Java class has a State and Behavior
State (Variables) 
Variable or Field is nothing but the property of the 
class 
class “computer” may have property like : 
– Model 
– mem_size 
– hd_size 
– os_type etc
Class Names 
first letter should be 
in Upper Case 
If several words are used to form a name of the class each inner 
words first letter should be in Upper Case. 
Ex: MyFirstJavaExample
Behavior (Methods) 
Method is nothing but the operation that an object 
can perform 
It tells How an object can interact with outside 
world
Method Names 
All method names should 
start with a Lower Case letter. 
Ex: 
public void myMethodName( )
Java Application 
Java classes having main method
main method 
should be public 
– because Class loader need to access this method 
should be static 
– because method would be executed without an 
object
HelloWorld.java
Compile the source file
Java is Case Sensitive 
● Both the compiler (javac) and launcher (java) 
are case-sensitive. 
● Type all code, commands, and file names 
exactly as shown. 
– HelloWorld is not the same as helloworld
Program File Name 
Name of the program file should exactly match the 
class name. 
When saving the file you should save it using the 
class name and append ‘.java’ to the end of the 
name. 
Example : 
Assume ‘HelloWorld’ is the class name. Then the 
file should be saved as ‘HelloWorld.java’
Java Identifiers 
All java components require names. 
Names used for classes, variables and methods 
are called identifiers.
Java Keywords 
These are reserved words and may not be used 
as constant or variable or any other identifier 
names. 
Examples: 
abstract, boolean, break, byte, class, package etc.
Comments in Java 
Java supports single line and multi-line comments 
very similar to c and c++. 
All characters available inside any comment are 
ignored by Java compiler.
Using Blank Lines 
A line containing only whitespace is known as a 
blank line, and Java ignores it.

More Related Content

What's hot

Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in JavaRavi_Kant_Sahu
 
Introducing classes
Introducing classesIntroducing classes
Introducing classesRiaz Ahmed
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingNithyaN19
 
Access modifiers
Access modifiersAccess modifiers
Access modifiersJadavsejal
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++vivekkumar2938
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questionsDhivyashree Selvarajtnkpm
 
Access specifier
Access specifierAccess specifier
Access specifierzindadili
 
Classes and objects
Classes and objectsClasses and objects
Classes and objectsAnil Kumar
 
More oop in java
More oop in javaMore oop in java
More oop in javaSAGARDAVE29
 
Java tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inJava tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inTIB Academy
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packagesKuntal Bhowmick
 
2- Introduction to java II
2-  Introduction to java II2-  Introduction to java II
2- Introduction to java IIGhadeer AlHasan
 
5- Overriding and Abstraction In Java
5- Overriding and Abstraction In Java5- Overriding and Abstraction In Java
5- Overriding and Abstraction In JavaGhadeer AlHasan
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and PolymorphismKartikKapgate
 
Interface in Java
Interface in JavaInterface in Java
Interface in JavaDucat India
 

What's hot (20)

Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Introducing classes
Introducing classesIntroducing classes
Introducing classes
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Access specifiers (Public Private Protected) C++
Access specifiers (Public Private  Protected) C++Access specifiers (Public Private  Protected) C++
Access specifiers (Public Private Protected) C++
 
Java classes and objects interview questions
Java classes and objects interview questionsJava classes and objects interview questions
Java classes and objects interview questions
 
Features of java technology
Features of java technologyFeatures of java technology
Features of java technology
 
Access specifier
Access specifierAccess specifier
Access specifier
 
C# Access modifiers
C# Access modifiersC# Access modifiers
C# Access modifiers
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
More oop in java
More oop in javaMore oop in java
More oop in java
 
Java tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inJava tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.in
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packages
 
Nested class in java
Nested class in javaNested class in java
Nested class in java
 
Java packages
Java packagesJava packages
Java packages
 
2- Introduction to java II
2-  Introduction to java II2-  Introduction to java II
2- Introduction to java II
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
5- Overriding and Abstraction In Java
5- Overriding and Abstraction In Java5- Overriding and Abstraction In Java
5- Overriding and Abstraction In Java
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Interface in Java
Interface in JavaInterface in Java
Interface in Java
 

Viewers also liked (11)

Identifiers
Identifiers Identifiers
Identifiers
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
 
Java keywords
Java keywordsJava keywords
Java keywords
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Introduction to class in java
Introduction to class in javaIntroduction to class in java
Introduction to class in java
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 

Similar to Java basic-syntax

Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 
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
 
Java syntax-and-grammars-oct8
Java syntax-and-grammars-oct8Java syntax-and-grammars-oct8
Java syntax-and-grammars-oct8MISSIASABTAL1
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2Raghu nath
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objectsvmadan89
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Ayes Chinmay
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - JavaDaniel Ilunga
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented PrinciplesSujit Majety
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitishChaulagai
 

Similar to Java basic-syntax (20)

Basic syntax
Basic syntaxBasic syntax
Basic syntax
 
Java basics
Java basicsJava basics
Java basics
 
java
java java
java
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
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
 
Computer programming 2 chapter 1
Computer programming 2  chapter 1Computer programming 2  chapter 1
Computer programming 2 chapter 1
 
Java syntax-and-grammars-oct8
Java syntax-and-grammars-oct8Java syntax-and-grammars-oct8
Java syntax-and-grammars-oct8
 
Java notes
Java notesJava notes
Java notes
 
Java PPt.ppt
Java PPt.pptJava PPt.ppt
Java PPt.ppt
 
1. intro
1. intro1. intro
1. intro
 
Basics of java 2
Basics of java 2Basics of java 2
Basics of java 2
 
INTRODUCTION TO JAVA
INTRODUCTION TO JAVAINTRODUCTION TO JAVA
INTRODUCTION TO JAVA
 
java01.ppt
java01.pptjava01.ppt
java01.ppt
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
 
Object Oriented Programming - Java
Object Oriented Programming -  JavaObject Oriented Programming -  Java
Object Oriented Programming - Java
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptx
 
Oop in kotlin
Oop in kotlinOop in kotlin
Oop in kotlin
 

More from Shahid Rasheed

More from Shahid Rasheed (7)

Java Variable Storage
Java Variable StorageJava Variable Storage
Java Variable Storage
 
Java Instantiation
Java InstantiationJava Instantiation
Java Instantiation
 
Variable Naming Best Practices
Variable Naming Best PracticesVariable Naming Best Practices
Variable Naming Best Practices
 
Java Variable Types
Java Variable TypesJava Variable Types
Java Variable Types
 
Java Basic Operators
Java Basic OperatorsJava Basic Operators
Java Basic Operators
 
Java basic-data-types
Java basic-data-typesJava basic-data-types
Java basic-data-types
 
What is-java
What is-javaWhat is-java
What is-java
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
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
 
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
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
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
 
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
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
“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
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
_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
 
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
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
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
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
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
 
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...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
“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...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
_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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Java basic-syntax

  • 1. Java Class Java class has a State and Behavior
  • 2. State (Variables) Variable or Field is nothing but the property of the class class “computer” may have property like : – Model – mem_size – hd_size – os_type etc
  • 3. Class Names first letter should be in Upper Case If several words are used to form a name of the class each inner words first letter should be in Upper Case. Ex: MyFirstJavaExample
  • 4. Behavior (Methods) Method is nothing but the operation that an object can perform It tells How an object can interact with outside world
  • 5. Method Names All method names should start with a Lower Case letter. Ex: public void myMethodName( )
  • 6. Java Application Java classes having main method
  • 7. main method should be public – because Class loader need to access this method should be static – because method would be executed without an object
  • 10. Java is Case Sensitive ● Both the compiler (javac) and launcher (java) are case-sensitive. ● Type all code, commands, and file names exactly as shown. – HelloWorld is not the same as helloworld
  • 11. Program File Name Name of the program file should exactly match the class name. When saving the file you should save it using the class name and append ‘.java’ to the end of the name. Example : Assume ‘HelloWorld’ is the class name. Then the file should be saved as ‘HelloWorld.java’
  • 12. Java Identifiers All java components require names. Names used for classes, variables and methods are called identifiers.
  • 13. Java Keywords These are reserved words and may not be used as constant or variable or any other identifier names. Examples: abstract, boolean, break, byte, class, package etc.
  • 14. Comments in Java Java supports single line and multi-line comments very similar to c and c++. All characters available inside any comment are ignored by Java compiler.
  • 15. Using Blank Lines A line containing only whitespace is known as a blank line, and Java ignores it.