0% found this document useful (0 votes)
3 views4 pages

Java Keywords - 1

Java keywords are reserved words with predefined meanings that cannot be used as identifiers. There are over 50 keywords that serve various purposes, including data type declarations, control flow, exception handling, and access modifiers. Keywords are case-sensitive and form the essential building blocks of Java's syntax.

Uploaded by

nishant.k
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Java Keywords - 1

Java keywords are reserved words with predefined meanings that cannot be used as identifiers. There are over 50 keywords that serve various purposes, including data type declarations, control flow, exception handling, and access modifiers. Keywords are case-sensitive and form the essential building blocks of Java's syntax.

Uploaded by

nishant.k
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Keywords

1. What Are Keywords in Java?


Keywords are reserved words in Java that have a predefined meaning in the language syntax. They cannot be
used as identifiers (variable names, class names, method names, etc.).
Java has a fixed set of keywords (currently 50+), and they form the building blocks of the language’s structure.

2. Characteristics of Java Keywords


●​ Predefined and reserved by the Java language.
●​ Cannot be redefined or used as variable names.
●​ Used to define data types, flow control, exception handling, class structure, and more.
●​ Keywords are case-sensitive (if is valid, If is not).​

3. List of Java Keywords (Grouped by Category)

A. Data Type & Declaration Keywords - Used to define variables, return types, and constants.
Keyword Purpose

int Defines integer type

float Defines floating-point number

double Defines double-precision floating point

boolean Defines true/false values

char Defines a single character

byte Defines 8-bit integer

short Defines 16-bit integer

long Defines 64-bit integer

void Used as return type for methods with no return

final Declares constant or unchangeable class/method/variable

static Denotes a class-level member


B. Class, Object & Interface Declaration Keywords
Keyword Purpose

class Declares a class

interface Declares an interface

enum Declares an enumeration

abstract Declares an abstract class or method

extends Indicates class inheritance

implements Indicates interface implementation

new Creates new object

this Refers to current object instance

super Refers to superclass object

C. Control Flow / Decision-Making Keywords


Keyword Purpose

if Executes code if condition is true

else Executes code if condition is false

switch Selects one of many code blocks

case Defines block under a switch label

default Executes if no case matches

break Exits loop or switch block

continue Skips current loop iteration

return Exits from a method and optionally returns a value


D. Looping Keywords
Keyword Purpose

for Used for loop with defined iteration

while Used for loop with precondition check

do Executes loop body before condition check

E. Exception Handling Keywords


Keyword Purpose

try Defines a block of code that may throw exception

catch Catches and handles exceptions

finally Defines cleanup code that always runs

throw Used to manually throw an exception

throws Declares exceptions a method may throw

F. Access & Modifiers Keywords


Keyword Purpose

public Access from anywhere

private Access within the same class only

protected Access within the same package or subclass

default* Package-private access (when no modifier is used)

final Prevents modification (reassignment, override, inheritance)

static Associated with class rather than instance

G. Class Behavior & Multithreading Keywords


Keyword Purpose

synchronized Used to control access to code by multiple threads

volatile Ensures changes to variable are visible to all threads

transient Prevents serialization of a variable

native Indicates method is implemented in native (C/C++) code


H. Others (Special Use Keywords)
Keyword Purpose

package Declares package name

import Imports other classes or packages

instanceof Tests if object is instance of specific class

assert Tests assumptions with assertion

strictfp Ensures floating-point calculations follow IEEE standards

I. Reserved but Unused Keywords


Java reserves a few keywords for future use (you can’t use them, but they have no current meaning):
const, goto

You might also like