SlideShare a Scribd company logo
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

PDF
Java basic syntax
PDF
Java basic-syntax
PDF
Java Basic Syntax
PPTX
Java basics
PDF
Lecture 10
PPTX
[OOP - Lec 07] Access Specifiers
PPT
Inner Classes
PDF
JAVA PROGRAMMING – Packages - Stream based I/O
Java basic syntax
Java basic-syntax
Java Basic Syntax
Java basics
Lecture 10
[OOP - Lec 07] Access Specifiers
Inner Classes
JAVA PROGRAMMING – Packages - Stream based I/O

What's hot (20)

PDF
Classes and Nested Classes in Java
PPTX
Introducing classes
PPTX
Java Inheritance - sub class constructors - Method overriding
PDF
Access specifiers (Public Private Protected) C++
DOC
Java classes and objects interview questions
PPSX
Features of java technology
PPTX
Access specifier
PPTX
C# Access modifiers
PPTX
Classes and objects
PPTX
More oop in java
PPTX
Java tutorial for beginners-tibacademy.in
DOCX
Class notes(week 7) on packages
DOCX
Nested class in java
PDF
Java packages
PPTX
2- Introduction to java II
PPTX
5- Overriding and Abstraction In Java
PPTX
Inheritance and Polymorphism
PPTX
Interface in Java
PPTX
Polymorphism
Classes and Nested Classes in Java
Introducing classes
Java Inheritance - sub class constructors - Method overriding
Access specifiers (Public Private Protected) C++
Java classes and objects interview questions
Features of java technology
Access specifier
C# Access modifiers
Classes and objects
More oop in java
Java tutorial for beginners-tibacademy.in
Class notes(week 7) on packages
Nested class in java
Java packages
2- Introduction to java II
5- Overriding and Abstraction In Java
Inheritance and Polymorphism
Interface in Java
Polymorphism
Ad

Viewers also liked (11)

PPTX
Identifiers
PPT
PPT
Basic elements of java
PDF
Java keywords
PPT
Java Server Pages
PPS
Introduction to class in java
PPTX
PDF
Introduction to Java Programming Language
PPT
Java tutorial PPT
PPT
Core java slides
PPTX
Introduction to java
Identifiers
Basic elements of java
Java keywords
Java Server Pages
Introduction to class in java
Introduction to Java Programming Language
Java tutorial PPT
Core java slides
Introduction to java
Ad

Similar to Java basic-syntax (20)

PPTX
Basic syntax
PPTX
Computer programming 2 chapter 1
PPTX
cs213Lecture_1 java programming oopsss.pptx
DOCX
java traning report_Summer.docx
PDF
Javaprogbasics
PPTX
Basics of java 2
PPTX
Core Java Tutorials by Mahika Tutorials
PPT
JAVA ppt tutorial basics to learn java programming
PPT
PPT
Introduction what is java
PPT
PPT
Java01
PPT
RIBBUN SOFTWARE
PPT
PPT
PPT
Java Simple Introduction in single course
PPT
java01.pptbvuyvyuvvvvvvvvvvvvvvvvvvvvyft
PPT
Lesson2
PPT
Lesson2
PPT
Lesson2
Basic syntax
Computer programming 2 chapter 1
cs213Lecture_1 java programming oopsss.pptx
java traning report_Summer.docx
Javaprogbasics
Basics of java 2
Core Java Tutorials by Mahika Tutorials
JAVA ppt tutorial basics to learn java programming
Introduction what is java
Java01
RIBBUN SOFTWARE
Java Simple Introduction in single course
java01.pptbvuyvyuvvvvvvvvvvvvvvvvvvvvyft
Lesson2
Lesson2
Lesson2

More from Shahid Rasheed (7)

PDF
Java Variable Storage
PDF
Java Instantiation
PDF
Variable Naming Best Practices
PDF
Java Variable Types
PDF
Java Basic Operators
PDF
Java basic-data-types
PDF
What is-java
Java Variable Storage
Java Instantiation
Variable Naming Best Practices
Java Variable Types
Java Basic Operators
Java basic-data-types
What is-java

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Complications of Minimal Access Surgery at WLH
PDF
TR - Agricultural Crops Production NC III.pdf
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
Final Presentation General Medicine 03-08-2024.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Pharma ospi slides which help in ospi learning
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Business Ethics Teaching Materials for college
PDF
Classroom Observation Tools for Teachers
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Complications of Minimal Access Surgery at WLH
TR - Agricultural Crops Production NC III.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 Đ...
Final Presentation General Medicine 03-08-2024.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Pharma ospi slides which help in ospi learning
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Pre independence Education in Inndia.pdf
Microbial diseases, their pathogenesis and prophylaxis
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program
Insiders guide to clinical Medicine.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Anesthesia in Laparoscopic Surgery in India
O7-L3 Supply Chain Operations - ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Business Ethics Teaching Materials for college
Classroom Observation Tools for Teachers

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.