Reserved Words in java
Reserved words:
Few words are reserved to provide some functionality or meaning,such type of reserved identifiers in java are called reserved words.
Diagram:
Reserved words(53)
|
|
_ _ _ _ _ __|_ _ _ _ _ _ _ _ _
| |
| |
Keywords(50) Reserved Literals(3)
| |
_ _ _ _ _|_ _ _ __ _ _ _ _ _ _ | __ _ __ _ _ _ _ _
| | | | | |
| | | | | |
Used keywords(48) unused keyword(2) true false null
|
|----->goto
|
|----->const
Reserved words for data types: (8)
1. byte
2. short
3. int
4. float
5. double
6. char
7. boolean
Reserved words for flow control:(11)
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:(11)
1. public
2 private
3. protected
4. static
5. final
6. abstract
7. synchronized
8. native
9. strictfp (1.2 version)
10. transient
11. volatile
Keywords for exception handling:(6)
1. try
2. catch
3. finally
4. throw
5. throws
6. assert (1.4 version)
Class related keywords:(6)
1. class
2. package
3. import
4. extends
5. implements
6. interface
Object related keywords:(4)
1. new
2. instanceof
3. super
4. this
Void return type keyword:
In java,if a method won't return anything compulsory that method should be declared with the void return type but it is optional in C++.
1. void
Unused keywords:
goto: It has created 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 can get compile time
error.
Reserved literals:
values for boolean data type.
1. true
2. false
3. null
Enum:
This keyword introduced in 1.5 version of java to define a group of named constants
Example:
enum Chocalate
{
Cadbury, KitKat, Eclairs, Perks;
}
Conclusions :
1. All reserved words contain only lowercase alphabet symbols in java.
2. New keywords in java are:
3. strictfp-----------1.2v
4. assert-------------1.4v
5. enum--------------1.5v
6. In java we have only new keyword but not deleted old one because destruction of useless objects is the responsibility
of Garbage Collection.
7. instanceof but not instanceOf
8. strictfp but not strictFp
9. const but not Constant
10. synchronized but not synchronize
11. extends but not extend
12. implements but not implement
13. import but not imports
14. int but not Int
Which of the following list contains only reserved words in java?
1. finalize, finally,final (invalid) //here finalize is a method in Object class.
2. long, Integer, short,byte (invalid) //here Integer is a wrapper class
3. new, delete (invalid) //delete is not a keyword
4. synchronized,finalize (invalid) //finalize is a method in Object class
5. break, return, exit, continue (invalid) //exit is not reserved keyword
6. constant,goto (invalid) //here constant is not reserved keyword
7. throw, throws, thrown (invalid)//thrown is not available in java
8. extends, imports, implements (invalid)//imports keyword is not available in java
9. sizeOf,instanceof (invalid)//sizeOf is not reserved keyword
10. None of the above (valid)
Which of the following are valid java keywords?
1. public (valid)
2. static (valid)
3. void (valid)
4. main (invalid)
5. String (invalid)
6. args (invalid)
Today's inspirational quotes:
"If you can dream it,you can do it. "
Happy Reading.Happy Learning!!! See you in next post :)
"If you can dream it,you can do it. "
Steps to Subscribe my blog in 15 secs:
1. Enter your mail id in "Subscribe" box.
2. Enter Captcha for verification.
3. A mail will be received with link in your mail id.Just Click on link and then Done .Thank you for subscribing :)
Happy Reading.Happy Learning!!! See you in next post :)
Post a Comment