Programming Keywords Table
The "Do Not Touch" list of programming. Explore reserved words across Python, JavaScript, Java, and C++.
Explorer
Filters
Python Keywords (35)
The Grammar of Code
Every human language has rules. You can't just use words in any order and expect to be understood. Programming languages are even stricter.
Keywords (or "reserved words") are the foundational building blocks of a language's syntax. They are the commands that tell the computer how to make decisions, loop through data, or define objects.
Because these words are so critical to the parser (the part of the compiler that reads your code), they are protected. You cannot use them for your own identifiers.
The "Syntax Error" Trap
Beginners often hit this wall. Tried to name a request variable class? Or a boolean true? The compiler will throw an error immediately because it thinks you are trying to define a class structure, not a variable.
class = "History 101" <-- NO!
Naming Conventions
If you really need to use a reserved word (like "class"), the convention in Python is to add a trailing underscore: class_. In C#, you can sometimes use the @ prefix. But usually, it's better to just pick a synonym like category or group.
class_name = "History 101" <-- YES!
Categories of Keywords
Control Flow
These words direct the flow of execution. They are the traffic signals of your code.
if, else, while, for, break, return, goto
Data Types & Values
In statically typed languages (Java, C++), these define what kind of data a variable holds.
int, float, boolean, char, void, null, true, false
Structure & Modifiers
These define the architecture of your program: classes, scopes, and visibility.
class, interface, public, private, static, package, import
Frequently Asked Questions
What exactly is a "reserved keyword"?
A reserved keyword is a word that has a special meaning to the compiler or interpreter. Because the language uses these words to define its own structure (like "if", "while", "class"), you are strictly forbidden from using them as names for your variables, functions, or classes.
What happens if I use a keyword as a variable name?
You will get a Syntax Error. For example, in Python, if you try to write "class = 5", the program will crash immediately because "class" is reserved for defining objects. The compiler gets confused and stops.
Are keywords case-sensitive?
Yes, in most modern languages like Python, Java, C++, and JavaScript. For example, "while" is a keyword, but "While" (capitalized) is not. However, using "While" as a variable name is considered very bad practice as it confuses other programmers.
Which language has the most keywords?
Of the popular languages, C++ has a very large set (over 90 keywords) due to its complexity and low-level features. Python, by contrast, is designed to be simple and has only about 35 keywords. COBOL is famous for having over 300!
What is a "contextual keyword"?
A contextual keyword is reserved only in specific situations. For example, in C#, "get" and "set" are keywords when defining properties, but you can use them as variable names elsewhere. This allows languages to add new features without breaking old code.
Why did you include "yield" in Python?
"yield" is a powerful keyword used in Generators. Instead of returning a value and exiting, a function with "yield" pauses execution and saves its state, allowing it to resume later. This is great for memory-efficient iteration.
Why does JavaScript have "let", "var", and "const"?
"var" is the old way (function-scoped). "let" and "const" were added in ES6 (block-scoped) to fix common bugs. "const" creates a read-only reference, while "let" allows reassignment. You should default to "const" unless you need to change the value.
What does "static" mean in Java/C++?
"static" means the member belongs to the CLASS itself, not to instances of the class. A static variable is shared by all objects. A static method can be called without creating an object (like Math.abs()).
What is the "void" keyword?
In typed languages like Java and C++, "void" is used effectively as a return type to indicate that a function does NOT return a value. It performs an action and then just finishes.
Can I define my own keywords?
No, you cannot add new keywords to a language unless you modify the compiler source code itself. However, you can write libraries or macros (in C++) that feel like language extensions.
What is "transient" in Java?
"transient" is used in serialization. It tells the JVM to ignore this specific field when saving an object's state to a file or stream. This is useful for sensitive data like passwords that shouldn't be persisted.
What is "volatile"?
"volatile" is a modifier used in multi-threaded programming. It tells the compiler that a variable's value might change unexpectedly (by another thread) and prevents the compiler from caching it, ensuring all threads see the most up-to-date value.
Why is "goto" considered harmful?
"goto" jumps execution deeply into another part of code without structure. This creates "Spaghetti Code" that is impossible to debug or trace. Most modern languages (like Java) reserve the word but don't even implement it to prevent its use!
What is the difference between "interface" and "abstract class"?
An "interface" (Java) implies a contract: the class MUST implement these methods. An "abstract class" can provide some default code implementation. A class can implement multiple interfaces but only extend one abstract class.
What does "pass" do in Python?
"pass" is a null statement. It literally does nothing. It is used as a placeholder when syntax requires a statement but you don't want to write code yet (e.g., in an empty function or class definition).