Java Keywords

Java Keywords are also known as reserved words in JAVA. Java Keywords are predefined in JAVA and they are used for some internal process or represent some predefined actions. There are a number of Java Keywords which plays an important role. We will discuss them in a separate post.

RULE: These are words not allowed to use as variable names or objects.

  1. abstract: abstract keyword is used to declare an abstract method or abstract class. That class or method will be implemented later, in a subclass
  2. boolean: It is used to declare a boolean variable that can hold only true or false.
  3. break: It is used in loops and witch statement. It breaks the control flow based on conditions.
  4. byte: It is used to declare a variable that can hold 8-bits data values.
  5. case: It used in switch statements to mark a block of code.
  6. catch: This keyword is used in exception handling to catch the exceptions that are generated by try block.
  7. char: It is used to declare a variable of a character type that can hold unsigned 16-bit Unicode characters
  8. class: This keyword is used to declare a new class.
  9. continue: It is used in loops. It continues the current flow of the program and skips the remaining code at the specified condition.
  10. default: default keyword is used in the switch block to specify the default block. It is also used in access modifiers.
  11. do: It is used in do-while loop
  12. double: It is used to declare a variable that can hold 64-bit floating-point numbers.
  13. else: It is used in if-else statements.
  14. enum: It is used to declare enum(Enumeration). It is used to define a fixed set of constants.
  15. extends: It is used to inheritance to extends the class.
  16. final: This keyword is used to declare a variable that holds constant value.
  17. finally: It is used in exception handling.
  18. float: Java float keyword is used to declare a variable that can hold a 32-bit floating-point number.
  19. for: It is a keyword that is used to define for a loop.
  20. if: It is the keyword used to test the condition.
  21. implements: It is used to implement the interface.
  22. import: It is used to import/access the class or interface to the current source.
  23. instanceOf: It is used to test the object is an instance of a class or interface.
  24. int: It is used to declare a variable that can hold a 32-bit signed integer.
  25. interface: it is a keyword that is used to declare the interface. The interface can hold only abstract methods.
  26. long:  long keyword is used to declare a variable that can hold a 64-bit integer.
  27. native: It is used to specify that a method is implemented with native code
  28. new: It is used to create new objects.
  29. null: It means an object doesn’t refer anything.
  30. package: It is used to define a package that includes classes.
  31. private: Its an access modifier that can use with class, variable or method. If variables or method is private, then it can’t be accessible from outside the class.
  32. protected: It’s an access modifier that can use with variable or method. If variable or method are protected, It can be accessible within the package and outside the package but through inheritance only.
  33. public: It’s an access modifier that can use with class, variable or method. If variables or method is private, then it can be accessed from outside the class or anywhere.
  34. return: It is used in a method to return from the method when execution gets completed.
  35. short: Java short keyword is used to declare a variable that can hold a 16-bit integer.
  36. static: It is used for memory management.
  37. strictfp: It is used to restrict the precision and rounding of floating-point calculations to ensure portability.
  38. super: It is used to refer parent class or parent’s class method.
  39. switch: It’s used in a switch statement that executes different blocks based of conditions.
  40. synchronized: Used with method/section in multi-threading
  41. this: Used to refer to the current object.
  42. throw: Used to throw the exception from try block
  43. throws: Used to throw multiple exceptions from method
  44. transient: It does not want to serialize the variable.
  45. try: It is used in exception handling.
  46. void: If the method doesn’t return anything.
  47. volatile: If we used it with variable it means variable may change asynchronously.
  48. while: while is a keyword that used in while loop
Java keywords

Leave a Comment