Java Programming – Class, Object, Keyword, Identifier,

Classes and Objects

A class is a template or blueprint. For example, a class called Student will have objects like name, roll number, marks etc.


<class modifiers> class <class name> [extends clause] [implements clause]


           [field declarations]

           [constructor declarations]

           [method declarations]


The UML (Unified Modeling Language) notation for the class is:

<class name>

class Box{

//Field declaration
int width;
int height;
int depth;
//Constructor Box(int, int, int)
Box(int w, int h, int d)
width = w;
height = h;
//Method declaration
int volume()
return width*height*depth;



An instance of a class is called an object. In Java, the object is created using ‘new’ keyword. The object creation process involves following three steps:

  • Declaring reference variable
  • Construction an object using ‘new’ keyword.
  • Assigning Reference value (address) to reference variable.

Box b = new Box(1,2,3);

  • The fields of a class are also called an attribute, properties, instance variable, or data member.
  • The methods of a class are also called as behavior, operation, instance method, or method member.
  • The data member and method member of a class are called a member of a class.
  • The new keyword creates an object and returns the reference value to the reference variable.


The name of a program is called an Identifier. An identifier is a sequence of characters. Identifiers are the names of the variables, methods, classes, packages, interfaces, arrays, enumerations, labeled names, etc.
class Welcome
public static void main(String[] args)
int age = 10;
System.out.println(“Welcome program”);


In java, the data types are grouped into two categories:

  • Primitive types
  • Reference types =>Classes, Interfaces, Exceptions, Errors, Enums, Annotations, and Arrays

Primitive types
There are 9 primitive types in java.
Below table summarizes the categories of the primitive types:


Primitive types

integers byte, short, int, long
floating point numbers float, double
Characters char
Booleans boolean
empty set data type void

1. By default, all integers are initialized with 0.
2. By default, all floating point numbers are initialized with 0.0
3. By default, all characters are initialized with blank space.
4. By default, all booleans are initialized with false.
5. By default, all reference types are initialized with null.
6. The size of the primitive data types is fixed across all operating systems.
7. The java supports only signed integers but unsigned characters.


The keyword has a predefined meaning in the programming language. In jdk1.6, there are 50 keywords and 3 reserved literals.
The below table summaries keyword category for our better understanding:




Primitive data type

Control flow

Exception handling



Class related

Object related

Unused keywords

byte, short, int, long, float, double, char, boolean, void

if, else, switch, case, default, while, do, for, break, continue, return

try, catch, finally, throw, throws, assert

private, protected, public, final, static, abstract, interface, strictfp, native, transient, volatile, synchronized

 class, extends, implements, package, import, enum

new, this, super, instanceof

const, goto










About The Author

This site uses Akismet to reduce spam. Learn how your comment data is processed.