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

PPT
Basic elements of java
PPTX
Week 2: Getting Your Hands Dirty – Part 2
PPTX
Week 1: Getting Your Hands Dirty - Part 1
PPTX
L2 datatypes and variables
PPTX
Java Datatypes
PDF
L2 datatypes and variables
PPTX
OCA Java SE 8 Exam Chapter 2 Operators & Statements
PPTX
PCSTt11 overview of java
Basic elements of java
Week 2: Getting Your Hands Dirty – Part 2
Week 1: Getting Your Hands Dirty - Part 1
L2 datatypes and variables
Java Datatypes
L2 datatypes and variables
OCA Java SE 8 Exam Chapter 2 Operators & Statements
PCSTt11 overview of java

What's hot (20)

PPT
M C6java3
PPTX
Java Data Types and Variables
PPTX
#_ varible function
PDF
Python Data Types
PPT
M C6java2
PPTX
Type checking compiler construction Chapter #6
PPTX
OCP Java (OCPJP) 8 Exam Quick Reference Card
PPT
Primitive data types in java
PPTX
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
PPTX
Java tokens
PPTX
Android webinar class_java_review
PPTX
Quick Scala
PDF
Compiler Construction | Lecture 7 | Type Checking
PPT
Introduction to objects and inputoutput
PDF
Inheritance
PPTX
Java platform
PDF
Lecture02 java
PPTX
Fundamental programming structures in java
M C6java3
Java Data Types and Variables
#_ varible function
Python Data Types
M C6java2
Type checking compiler construction Chapter #6
OCP Java (OCPJP) 8 Exam Quick Reference Card
Primitive data types in java
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
Java tokens
Android webinar class_java_review
Quick Scala
Compiler Construction | Lecture 7 | Type Checking
Introduction to objects and inputoutput
Inheritance
Java platform
Lecture02 java
Fundamental programming structures in java
Ad

Similar to ITFT - Java (20)

PPTX
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
PPTX
Introduction to JcjfjfjfkuutyuyrsdterdfbvAVA.pptx
PPT
Jacarashed-1746968053-300050282-Java.ppt
PPTX
Java fundamentals
PPTX
Introduction to java Programming Language
PPTX
Java Basics 1.pptx
PPTX
Java Tokens in java program . pptx
PPTX
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
PPT
demo1 java of demo 1 java with demo 1 java.ppt
PPTX
Chapter 2 java
PPTX
Basics of java 2
PPTX
Lecture2_MCS4_Evening.pptx
PPT
Core_java_ppt.ppt
PPT
Java
PPT
Md03 - part3
PPTX
Java programmingjsjdjdjdjdjdjdjdjdiidiei
PPT
java01.ppt
PPT
java01.pptbvuyvyuvvvvvvvvvvvvvvvvvvvvyft
PPT
Java Simple Introduction in single course
PPTX
OOP-java-variables.pptx
Java Unit-1.1 chunri kyu shuru kar rh koi si je di of du th n high ch ka dh h...
Introduction to JcjfjfjfkuutyuyrsdterdfbvAVA.pptx
Jacarashed-1746968053-300050282-Java.ppt
Java fundamentals
Introduction to java Programming Language
Java Basics 1.pptx
Java Tokens in java program . pptx
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
demo1 java of demo 1 java with demo 1 java.ppt
Chapter 2 java
Basics of java 2
Lecture2_MCS4_Evening.pptx
Core_java_ppt.ppt
Java
Md03 - part3
Java programmingjsjdjdjdjdjdjdjdjdiidiei
java01.ppt
java01.pptbvuyvyuvvvvvvvvvvvvvvvvvvvvyft
Java Simple Introduction in single course
OOP-java-variables.pptx
Ad

More from Blossom Sood (9)

PDF
ITFT- Dbms
PDF
ITFT - Web security
PDF
ITFT - Trends in it
PDF
ITFT - Search engine
PDF
ITFT - Oops
PDF
ITFT - Number system
PDF
ITFT - Java Coding
PDF
ITFT - DOS - Disk Operating System
PDF
ITFT - Window explorer
ITFT- Dbms
ITFT - Web security
ITFT - Trends in it
ITFT - Search engine
ITFT - Oops
ITFT - Number system
ITFT - Java Coding
ITFT - DOS - Disk Operating System
ITFT - Window explorer

Recently uploaded (20)

PPTX
Copy of ARAL Program Primer_071725(1).pptx
PPTX
Neurology of Systemic disease all systems
PPTX
ACFE CERTIFICATION TRAINING ON LAW.pptx
PPTX
MMW-CHAPTER-1-final.pptx major Elementary Education
PPTX
growth and developement.pptxweeeeerrgttyyy
PDF
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
PPTX
Neurological complocations of systemic disease
PPTX
Key-Features-of-the-SHS-Program-v4-Slides (3) PPT2.pptx
PDF
Kalaari-SaaS-Founder-Playbook-2024-Edition-.pdf
PDF
African Communication Research: A review
PDF
FYJC - Chemistry textbook - standard 11.
PPTX
Math 2 Quarter 2 Week 1 Matatag Curriculum
PPTX
2025 High Blood Pressure Guideline Slide Set.pptx
PDF
Diabetes Mellitus , types , clinical picture, investigation and managment
PDF
Chevening Scholarship Application and Interview Preparation Guide
PDF
Health aspects of bilberry: A review on its general benefits
DOCX
EDUCATIONAL ASSESSMENT ASSIGNMENT SEMESTER MAY 2025.docx
PDF
Physical pharmaceutics two in b pharmacy
PPTX
Cite It Right: A Compact Illustration of APA 7th Edition.pptx
PPTX
Theoretical for class.pptxgshdhddhdhdhgd
Copy of ARAL Program Primer_071725(1).pptx
Neurology of Systemic disease all systems
ACFE CERTIFICATION TRAINING ON LAW.pptx
MMW-CHAPTER-1-final.pptx major Elementary Education
growth and developement.pptxweeeeerrgttyyy
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
Neurological complocations of systemic disease
Key-Features-of-the-SHS-Program-v4-Slides (3) PPT2.pptx
Kalaari-SaaS-Founder-Playbook-2024-Edition-.pdf
African Communication Research: A review
FYJC - Chemistry textbook - standard 11.
Math 2 Quarter 2 Week 1 Matatag Curriculum
2025 High Blood Pressure Guideline Slide Set.pptx
Diabetes Mellitus , types , clinical picture, investigation and managment
Chevening Scholarship Application and Interview Preparation Guide
Health aspects of bilberry: A review on its general benefits
EDUCATIONAL ASSESSMENT ASSIGNMENT SEMESTER MAY 2025.docx
Physical pharmaceutics two in b pharmacy
Cite It Right: A Compact Illustration of APA 7th Edition.pptx
Theoretical for class.pptxgshdhddhdhdhgd

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.