Loading...
Java

Reserved Words

In Java some identifiers are reserved to associate some functionalities. Such reserved identifiers are called reserved words. There are 57 Reserved words and they are divided into 2 parts:
1. Keywords
2. Reserved literal

1. Key Words: They are 50 keywords. They are again divided into 2 types they are :
a) Used Keywords (they are 48)
b) Unused Keywords (they are 2)

2. Reserved Literals: They are 3 Reserved Literals.

Reserved words for data types:
1) byte
2) short
3) int
4) long
5) float
6) double
7) char
8) boolean

Reserved word for flow control:
1) if
2) else
3) switch
4) case
5) default
6) for
7) do
8) while
9) break
10) continue
11) return

Keywords for modifiers:
1) public
2) private
3) protected
4) static
5) final
6) abstract
7) synchronize
8) native
9) transient
10) strictfp
11) volatile

Keywords for exception handling:
1) try
2) throw
3) catch
4) throws
5) finally
6) assert

Class related keywords:
1) class
2) package
3) extends
4) interface
5) import
6) implements

Object related keywords:
1) super
2) this
3) new
4) instanceof

Void return type keyword:
If method wont return anything that method should be declared with void return.
1) void

Unused keywords:
1) goto: It created several problems in old languages so it is banned in java.
2) const: final key word is used instead of const.
If these keywords are used in the program we get compile time error.

Reserved Literals:
1) true —————–> Value for boolean data type.
2) false —————–> Value for boolean data type.
3) null —————–> default value for object reference.

Enum:
This keyword is introduced in 1.5v to define a group of named constants
Example:
enum Week
{
Sun, Mon, Tues, Wed, Thurs, Fri, Sat
}

Leave a Reply

Your email address will not be published. Required fields are marked *