What is a keyword in Java?

A keyword in Java is a reserved word that has a specific meaning and purpose within the language. Keywords cannot be used as identifiers (like variable names, method names, or class names) because they are part of Java's syntax. Each keyword has a predefined function and plays a vital role in defining the structure and behavior of the Java program.

Examples of Common Java Keywords:

  1. class: Defines a new class.
    public class Example { }
  2. public: Specifies the access level for classes, methods, and variables (accessible from anywhere).
    public void method() { }
  3. static: Indicates that a method or variable belongs to the class rather than instances of the class.
    public static void main(String[] args) { }
  4. void: Specifies that a method does not return any value.
    public void display() { }
  5. if: Used to create conditional statements.
    if (a > b) { }

Java has 52 Reserved Keywords, including:

  • Control flow statements: if, else, for, while, switch, case
  • Access modifiers: public, private, protected
  • Data types: int, char, boolean, float, etc.
  • Exception handling: try, catch, finally, throw, throws
  • OOP keywords: class, extends, implements, this, super

Special Keywords:

  • null, true, and false are not technically keywords but are reserved literals in Java.

Reference Sources:

TAGS
Coding Interview
CONTRIBUTOR
Arslan Ahmad
Arslan Ahmad
ex-FAANG engineering manager and author or Grokking series.
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
Working backward from desired outcomes to form coding strategies
What is the meaning of debugging?
What is remote software engineering?
Who is the CEO of Tesla?
Who is the head of HR at Amazon?
What is the highest paying job in OpenAI?
Related Courses
New
Grokking the AI System Design Interview course cover
Grokking the AI System Design Interview
Learn to design AI systems the way interviewers expect: classic ML products, LLM and RAG architectures, and agentic systems, all through the lens of the system design interview.
4.6
(3,192 learners)
Discounted price for Your Region

$123

Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
4.1
Discounted price for Your Region

$72

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.