SlideShare a Scribd company logo
Java object 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 Name
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 Name
All method names should
start with a Lower Case letter.
Ex:
public void myMethodName( )
Java Application
is a Java class having main method
main method
should be public
– Class loader need to access this method
should be static
– method would be executed without an object
HelloWorld.java
● Compile the code
– javac HelloWorld.java
● Run the code
– java HelloWorld
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 :
class ‘HelloWorld’ should be saved in file ‘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

PDF
Java basic-syntax
PDF
Java Basic Syntax
PPTX
Java basics
PDF
Lecture 10
PPTX
[OOP - Lec 07] Access Specifiers
PPTX
2- Introduction to java II
PPSX
Features of java technology
PPTX
5- Overriding and Abstraction In Java
Java basic-syntax
Java Basic Syntax
Java basics
Lecture 10
[OOP - Lec 07] Access Specifiers
2- Introduction to java II
Features of java technology
5- Overriding and Abstraction In Java

What's hot (19)

PDF
JAVA PROGRAMMING – Packages - Stream based I/O
PDF
Access specifiers (Public Private Protected) C++
PPT
Inner Classes
DOC
Java classes and objects interview questions
PPTX
Java Inheritance - sub class constructors - Method overriding
PPTX
More oop in java
PPTX
Introducing classes
PPTX
Access specifier
DOCX
Final Class in Java - By JavaGoal
PPTX
Inheritance and Polymorphism
PPTX
C# Access modifiers
DOCX
Class notes(week 7) on packages
PPT
Learn Java language fundamentals with Unit nexus
PDF
Java packages
PPTX
Java tutorial for beginners-tibacademy.in
PPTX
object oriented programming using c++
DOC
116824015 java-j2 ee
PPT
java tutorial 4
PPTX
JAVA PROGRAMMING – Packages - Stream based I/O
Access specifiers (Public Private Protected) C++
Inner Classes
Java classes and objects interview questions
Java Inheritance - sub class constructors - Method overriding
More oop in java
Introducing classes
Access specifier
Final Class in Java - By JavaGoal
Inheritance and Polymorphism
C# Access modifiers
Class notes(week 7) on packages
Learn Java language fundamentals with Unit nexus
Java packages
Java tutorial for beginners-tibacademy.in
object oriented programming using c++
116824015 java-j2 ee
java tutorial 4
Ad

Similar to Java basic syntax (20)

PPTX
Basic syntax
PPTX
Java basics
PDF
Basic Java Programming
PDF
DOCX
Java notes
PPTX
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
PPTX
Computer programming 2 chapter 1
PPTX
Java syntax-and-grammars-oct8
PPTX
Basics of java 2
PPT
Classes and Objects
PPT
Java PPt.ppt
PPTX
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
PPT
Java for Mainframers
PDF
Object Oriented Principles
PPT
INTRODUCTION TO JAVA
DOCX
Viva file
PPTX
Android Training (Java Review)
PPTX
Java_Roadmap.pptx
DOCX
Unit of competency
PPTX
classes-objects in oops java-201023154255.pptx
Basic syntax
Java basics
Basic Java Programming
Java notes
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
Computer programming 2 chapter 1
Java syntax-and-grammars-oct8
Basics of java 2
Classes and Objects
Java PPt.ppt
Internet and Web Technology (CLASS-15) [JAVA Basics] | NIC/NIELIT Web Technol...
Java for Mainframers
Object Oriented Principles
INTRODUCTION TO JAVA
Viva file
Android Training (Java Review)
Java_Roadmap.pptx
Unit of competency
classes-objects in oops java-201023154255.pptx
Ad

More from 3trg (9)

PDF
Pmd naming-rules
PDF
Suppressing warnings
PDF
Mark violation-for-review
PDF
Clearing violations
PDF
Checking code-with-pmd
PDF
Pmd eclipse
PDF
What is-pmd
PDF
Java basic data types
PDF
What is Java
Pmd naming-rules
Suppressing warnings
Mark violation-for-review
Clearing violations
Checking code-with-pmd
Pmd eclipse
What is-pmd
Java basic data types
What is Java

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Lesson notes of climatology university.
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Complications of Minimal Access Surgery at WLH
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Pre independence Education in Inndia.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
RMMM.pdf make it easy to upload and study
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial diseases, their pathogenesis and prophylaxis
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Anesthesia in Laparoscopic Surgery in India
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Lesson notes of climatology university.
VCE English Exam - Section C Student Revision Booklet
Microbial disease of the cardiovascular and lymphatic systems
GDM (1) (1).pptx small presentation for students
Complications of Minimal Access Surgery at WLH
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
human mycosis Human fungal infections are called human mycosis..pptx
PPH.pptx obstetrics and gynecology in nursing
Pre independence Education in Inndia.pdf
Insiders guide to clinical Medicine.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
RMMM.pdf make it easy to upload and study
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Cell Types and Its function , kingdom of life
2.FourierTransform-ShortQuestionswithAnswers.pdf

Java basic syntax

  • 1. Java object 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 Name 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 Name All method names should start with a Lower Case letter. Ex: public void myMethodName( )
  • 6. Java Application is a Java class having main method
  • 7. main method should be public – Class loader need to access this method should be static – method would be executed without an object
  • 9. ● Compile the code – javac HelloWorld.java ● Run the code – java HelloWorld
  • 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 : class ‘HelloWorld’ should be saved in file ‘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.