In
java some words are reserved words to represent some meaning or
functionality, such type of words are called as reserved words.
Real Example:
“Dog”
is a reserve word to represent one type of animal.
“Apple”
is a reserve word to represent one type of fruit.
“sleep”
is a reserve word to represent one type of action.
“eat”
is a reserve word to represent one type of action.
In
universe , there are millions of reserved words are there that we are
using in our language, but in the language java we need to remember
only 53 reserved words.
Note: Total
53 reserved words are there in java
Keywords:for
data type: (8)
[ byte,short,int,long,float,double,boolean,char ]
Keywords
for flow Control: (11)
[ if,else,switch,case,default,do,while,for,break,continue,return ]
Keywords
for Modifiers: (11)
[public,private,protected,static,final,abstract,synchronized,native,strictfp(java
1.2),transient,volatile]
Keywords
for Exception Handling: (6)
[ try,catch,finally,throw,throws,assert(java 1.4) ]
Class
Related Keyword: (6)
[ class,interface,extends,implements,package,import ]
Object
Related Keyword: (6)
[ new,instanceof,super,this ]
Void
Return Type Keyword: (1)
[ void ]
In
java,return type is mandatory. If a method wo'nt return anything,
then we have to declare that method with void return type, But in C
langugae return type is optional and the default return type is int.
UnUsed
Keywords: (2)
[ goto,const ]
goto
- -> usage of goto created several problems in old languages.
Hence SUN people banned this keyword in java.
const
--> use of final instead of const.
Note:
goto and const are unused keywords and if we are trying to use we ll
get compile time error.
Reserved
Word Literals: (3)
[ true,false,null ]
true,false-
values for boolean data type
null-
default value for object reference
enum
keyword(Introduced in java 1.5): (1)
[ enum ]
We
can use enum to define a group of named constants.
Example:
enum
month{
JAN,FEB,MAR...DEC;
}
Conclusion:
- All 53 reserved words in java contain only lower case alphabet symbols.
- In java, we have only new keyword, and there is no delete keyword because destruction of useless object is the responsibility of garbage collector.
- The following are new keywords in java.strictfp -->introduced in java 1.2assert -->introduced in java 1.4enum -->introduced in java 1.5
- Some confused reserved words are like:strictfp but not strictFpinstanceof but not instanceOfconst but not constantsynchronized but not synchronizeimport but not importsextends but not extendimplements but not implement
Question
1
Which of the following list contains java reserved words?
1.new,delete
2.goto,constant
3.break,continue,return,exit,
4.fianl,finally,finalize
5.throw,throws,thrown
6.notify,notifyAll
7.implements,extends,imports
8.sizeof,instanceof
9.instanceOf,strictFp
10.byte,short,Int
11.None
of the above
Question
2
Which of the following are java reserved words?
1.public
2.static
3.void
4.main
5.String
6.args
No comments:
Post a Comment