SlideShare a Scribd company logo
1 of 17
Download to read offline
Java
Class
• Class names should be nouns, in mixed case
• with the first letter of each internal word
capitalized.
• Try to keep your class names simple
• and descriptive. Use whole words—avoid
• acronyms and abbreviations
• Eg helloWorld,HelloWorld
Methods
• Methods should be verbs, in mixed case with
the first letter lowercase, with the first letter of
each internal word capitalized.
• run();
• runFast();
• getBackground();
Variables
• Except for variables, all instance, class, and
• class constants are in mixed case with a
lowercase
• first letter. Internal words start with capital
• letters.
• Variable names should be short yet meaningful.
• The choice of a variable name should be
mnemonic— that is, designed to indicate to the
use.
• int I;
• char
Basic Program
• class helloWorld
• {
• public static void main(String args[ ])
• {
• System.out.println(“Hello World!”);
• }
• }
Class Identification
• The class definition
• The first line is a declaration statement to
introduce the code to the computer before it
is used:
• class notifies the interpreter that a new class
will be defined.
• helloWorld is the unique name for this new
class.
• The curly braces signal the beginning and end
of the class body
The main method
• Atleast one and only one main method.
• Java applets, however, do not contain main methods.
• public is known as a 'global', a signal to the interpreter that this method
can be used in other parts of the program.
• The private keyword prevents the rest of the program from calling
anything inside a method.
• static tells the interpreter that the main method applies to everything
in the helloWorld class, rather than just one element. Breathing and
daily activities work as analogies for static and instance methods; daily
activities vary but breathing is required.
• void indicates that this method finishes operating without returning any
results.
• main is the unique identifier for this method and is a reserved word
because all Java applications have one and only one main method.
• The parentheses indicate that parameters can be passed to this method
main(String args[ ])
• The String array
• The third line declares an array, an element
that stores a list of values like x[1,2,3].
Contrast arrays with variables that store only
one value at a time, like x=3. String defines
the type of values received: numbers,
characters, and symbols. Args is the unique
name for this array, and the brackets signal its
array status.
System class & output
• System is a class in Java's default package and
handles system hardware.
• Out is an object of that class and handles
output.
• Println() is a method of System and accepts
Hello, world! as a parameter to output to the
screen.
• Interpreters normally ignore spaces in stored
values, so quotation marks declare this a
string parameter to preserve such characters.
Java Comments
• The Java programming language supports three kinds
of comments:
1. Double slashes in front of a single line comment:
int i=5; // Set the integer to 5
2. Matching slash-asterisk (/*) and asterisk-slash (*/) to bracket multi-line
comments:
/*
Set the integer to 5
*/
int i=5;
3. Matching slash-double asterisk (/**) & asterisk-slash(*/) for Javadoc automatic
hypertext documentation, as in
/**
This applet tests graphics.
Java Data and Variables
• byte
• Short
• int
• long
• float
• Double
• char
• boolean
Java Data and Variables
• Integer types have no fractional part; floating
point types have a fractional part. On paper,
integers have no decimal point, and floating
point types do. But in main memory, there are
no decimal points: even floating point values
are represented with bit patterns. There is a
fundamental difference between the method
used to represent integers and the method
used to represent floating point numbers.
Java Data and Variables
• Type Size
• byte ……….8 bits
• Short……… 16 bits
• int …………..32 bits
• Long……….. 64 bits
• float ……….32 bits
• double……. 64 bits
• variabletype variablename = data;
Java Data and Variables
• For each primitive type, there is a corresponding wrapper class.
A wrapper class can be used to convert a primitive data value
into an object, and some type of objects into primitive data. The
table shows primitive types and their wrapper class
• primitive type Wrapper type
• byte Byte
• short Short
• int Int
• long Long
• Float Float
• double Double
• char Character
• Boolean Boolean
Java Arithmetic Operators
• The Java programming language has includes five
simple arithmetic operators like are + (addition),
- (subtraction), * (multiplication), / (division),
and % (modulo).
• Use Returns true if
• op1 + op2 op1 added to op2
• op1 - op2 op2 subtracted from op1
• op1 * op2 op1 multiplied with op2
• op1 / op2 op1 divided by op2
• op1 % op2 Computes the remainder of
dividing op1 by op2
Java Data and Variables
• x && y Conditional
AND If both x and y are true, result is true.
If either x or y are false, the result is false
If x is false, y is not evaluated.
Access Modifiers
• The first (left-most) modifier used lets you
control what other classes have access to a
member field. For the moment, consider only
public and private.
• public modifier—the field is accessible from
all classes.
• private modifier—the field is accessible only
within its own class.
• In the spirit of encapsulation, it is common to
make fields private. This means that they can
only be directly accessed from the Bicycle
class. We still need access to these values,
however.

More Related Content

What's hot

Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
 
Fundamental programming structures in java
Fundamental programming structures in javaFundamental programming structures in java
Fundamental programming structures in java
Shashwat Shriparv
 

What's hot (20)

M C6java3
M C6java3M C6java3
M C6java3
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variables
 
#_ varible function
#_ varible function #_ varible function
#_ varible function
 
Python Data Types
Python Data TypesPython Data Types
Python Data Types
 
M C6java2
M C6java2M C6java2
M C6java2
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Primitive data types in java
Primitive data types in javaPrimitive data types in java
Primitive data types in java
 
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
 
Java tokens
Java tokensJava tokens
Java tokens
 
Variable
VariableVariable
Variable
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
 
Quick Scala
Quick ScalaQuick Scala
Quick Scala
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Introduction to objects and inputoutput
Introduction to objects and inputoutput Introduction to objects and inputoutput
Introduction to objects and inputoutput
 
Inheritance
InheritanceInheritance
Inheritance
 
Ch6
Ch6Ch6
Ch6
 
Java platform
Java platformJava platform
Java platform
 
Lecture02 java
Lecture02 javaLecture02 java
Lecture02 java
 
Fundamental programming structures in java
Fundamental programming structures in javaFundamental programming structures in java
Fundamental programming structures in java
 

Similar to ITFT - Java

demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.ppt
FerdieBalang
 
cs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptxcs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptx
mshanajoel6
 

Similar to ITFT - Java (20)

Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
 
Learning core java
Learning core javaLearning core java
Learning core java
 
basics dart.pdf
basics dart.pdfbasics dart.pdf
basics dart.pdf
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
OOP-java-variables.pptx
OOP-java-variables.pptxOOP-java-variables.pptx
OOP-java-variables.pptx
 
Preparing Java 7 Certifications
Preparing Java 7 CertificationsPreparing Java 7 Certifications
Preparing Java 7 Certifications
 
Java
JavaJava
Java
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
kotlin-nutshell.pptx
kotlin-nutshell.pptxkotlin-nutshell.pptx
kotlin-nutshell.pptx
 
demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.ppt
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
 
Java
JavaJava
Java
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
 
Enumerations in java.pptx
Enumerations in java.pptxEnumerations in java.pptx
Enumerations in java.pptx
 
Java Basics
Java BasicsJava Basics
Java Basics
 
cs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptxcs213Lecture_1 java programming oopsss.pptx
cs213Lecture_1 java programming oopsss.pptx
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 

More from Blossom Sood (9)

ITFT- Dbms
ITFT- DbmsITFT- Dbms
ITFT- Dbms
 
ITFT - Web security
ITFT - Web securityITFT - Web security
ITFT - Web security
 
ITFT - Trends in it
ITFT - Trends in itITFT - Trends in it
ITFT - Trends in it
 
ITFT - Search engine
ITFT - Search engineITFT - Search engine
ITFT - Search engine
 
ITFT - Oops
ITFT - OopsITFT - Oops
ITFT - Oops
 
ITFT - Number system
ITFT - Number systemITFT - Number system
ITFT - Number system
 
ITFT - Java Coding
ITFT - Java CodingITFT - Java Coding
ITFT - Java Coding
 
ITFT - DOS - Disk Operating System
ITFT - DOS - Disk Operating SystemITFT - DOS - Disk Operating System
ITFT - DOS - Disk Operating System
 
ITFT - Window explorer
ITFT - Window explorerITFT - Window explorer
ITFT - Window explorer
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

ITFT - Java

  • 2. Class • Class names should be nouns, in mixed case • with the first letter of each internal word capitalized. • Try to keep your class names simple • and descriptive. Use whole words—avoid • acronyms and abbreviations • Eg helloWorld,HelloWorld
  • 3. Methods • Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized. • run(); • runFast(); • getBackground();
  • 4. Variables • Except for variables, all instance, class, and • class constants are in mixed case with a lowercase • first letter. Internal words start with capital • letters. • Variable names should be short yet meaningful. • The choice of a variable name should be mnemonic— that is, designed to indicate to the use. • int I; • char
  • 5. Basic Program • class helloWorld • { • public static void main(String args[ ]) • { • System.out.println(“Hello World!”); • } • }
  • 6. Class Identification • The class definition • The first line is a declaration statement to introduce the code to the computer before it is used: • class notifies the interpreter that a new class will be defined. • helloWorld is the unique name for this new class. • The curly braces signal the beginning and end of the class body
  • 7. The main method • Atleast one and only one main method. • Java applets, however, do not contain main methods. • public is known as a 'global', a signal to the interpreter that this method can be used in other parts of the program. • The private keyword prevents the rest of the program from calling anything inside a method. • static tells the interpreter that the main method applies to everything in the helloWorld class, rather than just one element. Breathing and daily activities work as analogies for static and instance methods; daily activities vary but breathing is required. • void indicates that this method finishes operating without returning any results. • main is the unique identifier for this method and is a reserved word because all Java applications have one and only one main method. • The parentheses indicate that parameters can be passed to this method
  • 8. main(String args[ ]) • The String array • The third line declares an array, an element that stores a list of values like x[1,2,3]. Contrast arrays with variables that store only one value at a time, like x=3. String defines the type of values received: numbers, characters, and symbols. Args is the unique name for this array, and the brackets signal its array status.
  • 9. System class & output • System is a class in Java's default package and handles system hardware. • Out is an object of that class and handles output. • Println() is a method of System and accepts Hello, world! as a parameter to output to the screen. • Interpreters normally ignore spaces in stored values, so quotation marks declare this a string parameter to preserve such characters.
  • 10. Java Comments • The Java programming language supports three kinds of comments: 1. Double slashes in front of a single line comment: int i=5; // Set the integer to 5 2. Matching slash-asterisk (/*) and asterisk-slash (*/) to bracket multi-line comments: /* Set the integer to 5 */ int i=5; 3. Matching slash-double asterisk (/**) & asterisk-slash(*/) for Javadoc automatic hypertext documentation, as in /** This applet tests graphics.
  • 11. Java Data and Variables • byte • Short • int • long • float • Double • char • boolean
  • 12. Java Data and Variables • Integer types have no fractional part; floating point types have a fractional part. On paper, integers have no decimal point, and floating point types do. But in main memory, there are no decimal points: even floating point values are represented with bit patterns. There is a fundamental difference between the method used to represent integers and the method used to represent floating point numbers.
  • 13. Java Data and Variables • Type Size • byte ……….8 bits • Short……… 16 bits • int …………..32 bits • Long……….. 64 bits • float ……….32 bits • double……. 64 bits • variabletype variablename = data;
  • 14. Java Data and Variables • For each primitive type, there is a corresponding wrapper class. A wrapper class can be used to convert a primitive data value into an object, and some type of objects into primitive data. The table shows primitive types and their wrapper class • primitive type Wrapper type • byte Byte • short Short • int Int • long Long • Float Float • double Double • char Character • Boolean Boolean
  • 15. Java Arithmetic Operators • The Java programming language has includes five simple arithmetic operators like are + (addition), - (subtraction), * (multiplication), / (division), and % (modulo). • Use Returns true if • op1 + op2 op1 added to op2 • op1 - op2 op2 subtracted from op1 • op1 * op2 op1 multiplied with op2 • op1 / op2 op1 divided by op2 • op1 % op2 Computes the remainder of dividing op1 by op2
  • 16. Java Data and Variables • x && y Conditional AND If both x and y are true, result is true. If either x or y are false, the result is false If x is false, y is not evaluated.
  • 17. Access Modifiers • The first (left-most) modifier used lets you control what other classes have access to a member field. For the moment, consider only public and private. • public modifier—the field is accessible from all classes. • private modifier—the field is accessible only within its own class. • In the spirit of encapsulation, it is common to make fields private. This means that they can only be directly accessed from the Bicycle class. We still need access to these values, however.