Java Programming – Class, Object, Keyword, Identifier,

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest

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









Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on email

Leave a Reply

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

Recommended for you
Connect With Us
Stay Connected

Subscribe to our newsletter today to receive updates on latest tech news, tutorials SEO tips many more.

Latest Articles

5 Best Apps for self-development

We live in a world of high dynamicity, progress, and constant change. But in most times it has been observed that we are not that welcoming when it comes to changing ourselves or changing anything around us. We try to repel change as long as possible.

Free hub for guest blogging nerds and newbie writers

  • Submit Guest Post
  • Share your Knowledge
  • Build your Backlinks
  • Advertise your products
  • Make money by writing
Subscribe to our newsletter today to receive updates on latest tech news, tutorials SEO tips many more.