RESERVED WORDS:
In java some identifiers are reserved to associate some functionality or meaning such type of reserved identifiers are called reserved words.Diagram:
Reserved words for data types: (8)
- byte
- short
- int
- long
- float
- double
- char
- boolean
Reserved words for flow control:(11)
- if
- else
- switch
- case
- default
- for
- do
- while
- break
- continue
- return
Keywords for modifiers:(11)
- public
- private
- protected
- static
- final
- abstract
- synchronized
- native
- strictfp(1.2 version)
- transient
- volatile
Keywords for exception handling:(6)
- try
- catch
- finally
- throw
- throws
- assert(1.4 version)
Class related keywords:(6)
- class
- package
- import
- extends
- implements
- interface
Object related keywords:(4)
- new
- instanceof
- super
- this
Void return type keyword:
If a method won't return anything compulsory that method should be declared with the
void return type in java but it is optional in C++.
- void
Unused keywords:
goto:Create several problems in old languages and hence it is banned in java.
Const:Use final instead of this.
By mistake if we are using these keywords in our program we will get compile time
error.
Reserved literals:
- true---------values for boolean data type.
- false---------values for boolean data type.
- null-------- default value for object reference.
Enum:
This keyword introduced in 1.5v to define a group of named constants.
Example:
enum sports
{
bat, ball, stump;
}
Conclusions :
- All reserved words in java contain only lowercase alphabet symbols.
- New keywords in java are:
- strictfp-----------1.2v
- assert-------------1.4v
- enum--------------1.5v
- In java we have only new keyword but not delete because destruction of useless objects is the responsibility of Garbage Collection.
- instanceof but not instanceOf
- strictfp but not strictFp
- const but not Constant
- syncronized but not syncronize
- extends but not extend
- implements but not implement
- import but not imports
- int but not Int
Which of the following list contains only java reserved words ?
- final, finally, finalize (invalid) //here finalize is a method in Object class.
- throw, throws, thrown(invalid) //thrown is not available in java
- break, continue, return, exit(invalid) //exit is not reserved keyword
- goto, constant(invalid) //here constant is not reserved keyword
- byte, short, Integer, long(invalid) //here Integer is a wrapper class
- extends, implements, imports(invalid) //imports keyword is not available in java
- finalize, synchronized(invalid) //finalize is a method in Object class
- instanceof, sizeOf(invalid) //sizeOf is not reserved keyword
- new, delete(invalid) //delete is not a keyword
Comments
Post a Comment