Keywords in Java

Here are some of the top keywords in the Java programming language:

  1. class: Defines a class, which is a blueprint for creating objects.
  2. public: An access modifier that allows the class, method, or variable to be accessed from any other class.
  3. static: Denotes that a method or variable belongs to the class itself, rather than a specific instance of the class.
  4. void: Indicates that a method does not return any value.
  5. new: Creates a new instance of a class.
  6. if: Starts a conditional statement and specifies a block of code to be executed if the condition is true.
  7. else: Defines an alternative block of code to be executed if the preceding “if” condition is false.
  8. for: Initiates a loop that executes a block of code repeatedly until a specified condition is met.
  9. while: Starts a loop that executes a block of code as long as a specified condition is true.
  10. return: Terminates the execution of a method and returns a value to the caller.
  11. try: Defines a block of code in which exceptions may occur and can be caught and handled.
  12. catch: Catches an exception and specifies a block of code to handle the exception.
  13. finally: Defines a block of code that is always executed, regardless of whether an exception occurred.
  14. throw: Throws an exception manually to indicate that an error or unexpected condition has occurred.
  15. extends: Specifies that a class inherits from another class, establishing an inheritance relationship.
  16. implements: Indicates that a class implements one or more interfaces, defining the contract it must follow.
  17. interface: Declares an interface, which defines a set of methods that implementing classes must implement.
  18. package: Organizes classes into namespaces or modules, helping to manage the structure of a program.
  19. import: Allows the use of classes and packages from other packages without fully qualifying them.
  20. private: An access modifier that restricts the access of a class, method, or variable to within its own class.

These are some of the essential keywords in Java. Familiarity with these keywords is crucial for understanding and writing Java programs effectively.


About Manohar

I, Manohar am the founder and chief editor of ClarifyAll.com. I am working in an IT professional.

View all posts by Manohar →

Leave a Reply