Object Oriented Programming
Developed at Sun Microsystems in 1991
James Gosling, initially named “OAK”
Formally announced java in 1995
Object oriented and cant write proceduralprograms
Functions are called methods
Unit of a program is the class from whichobjects are created
Automatic garbage collection
Single inheritance only
Each class contains data and methods whichare used to manipulate the data
Programs are small and portable
Multithreaded which allows severaloperations to be executed concurrently
A rich set of classes and methods areavailable in java class libraries
Platform Independent
Case sensitive
Edit – use any editor
Compile – use command ‘javac’ifyour program compiles correctly, will create a file withextension .class
Execute – use the command ‘java’
Java program development
Keywords are special reserved words in java that youcannot use as identifiers for classes, methods orvariables. They have meaning to the compiler, it usesthem to understand what your source code is trying todo.
 
Java language keywords
class FirstPro  {
  public static void main(String args[])  {
     System.out.println("Hello World!“);
  }
}
First java Program
All java source files must end with the extension ‘.java’
Generally contain at most one top level public classdefinition
If a public class is present, the class name shouldmatch the file name
Java Source files
If these are present then they must appear in thefollowing order.
Package declarations
Import statements
Class definitions
Top level elements appears in a file
An identifier is a word used by a programmer to namea variable, method class or label.
Keywords may not be used as an identifier
Must begin with a letter, a dollar sign($) or anunderscore( _ ).
Subsequent character may be letters, digits, _ or $.
Cannot include white spaces.
 ref: Note
Identifiers
Type identifier;
Type identifier=initial value;
Declaring Variables
Primitive Data Types
Type
Bits
Range
boolean
1
true, false
char
16
0 to 65,535
byte
8
-128 to +127
short
16
-32,768 to +32,767
int
32
-232 to +232-1
long
64
-264 to +264-1
float
32
-3.4E+38 to +3.4E+38 (approx)
double
64
-1.8E+308 to +1.8E+308 (approx)
int grade; // an integer to hold a grade, no initial value
int grade = 0; // an integer to hold a grade with initialvalue 0
char answer; // an answer to something – one character
String name; // a string to hold a name
String name = "Gumboot"; // as above, with an initialvalue
boolean finished; // to hold "true" if finished
boolean finished = false; // as above, but with an initialvalue
Declarations
int grade;
char answer;
String name;
Assignments
grade = 70;
answer = 'a';
name = "alan turing";
Declarations and Assignments
Default Values
Data TypeData Type
Default Value (for fields)Default Value (for fields)
bytebyte
00
shortshort
00
intint
00
longlong
0L0L
floatfloat
0.0f0.0f
doubledouble
0.0d0.0d
charchar
'\u0000''\u0000'
String (or any object)  String (or any object)  
nullnull
booleanboolean
falsefalse