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
What is the full form of QC?
What is the best time for technical interview?
What Does L4 Mean in a Job, and Does Netflix Use It?
L4 is a level code for a mid-level engineer at companies that publish a ladder. Netflix does not publish one, so an L4 label at Netflix is unofficial.
What is called technical interview?
What is the highest job in Apple?
Why Are Google Interviews So Hard?
The questions are only part of it. The difficulty comes from speaking while you solve, repeating that across five sessions, and being judged on written notes.
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

$99

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.
About Us
Our Team
Careers
Partners
Contact Us
Become Affiliate
Copyright © 2026 Design Gurus, LLC. All rights reserved.