JAVA-Keywords - Notes By ShariqSP

Keywords in Java

Keywords in Java are reserved words that have predefined meanings and cannot be used as identifiers (such as variable names, class names, etc.). They play a crucial role in defining the syntax and structure of Java programs.

Keywords are used to define the control flow, data types, modifiers, and other aspects of Java programs. They provide specific functionalities and operations within the language.

Keyword Description
abstract Used to declare abstract classes and methods, which are incomplete and must be implemented by subclasses.
assert Enables assertion checking to test assumptions about the program's behavior.
boolean Defines a data type that can store either true or false values.
break Used to terminate a loop or switch statement prematurely.
byte Defines a data type that can store integer values from -128 to 127.
case Specifies a branch in a switch statement.
catch Handles exceptions thrown by try blocks.
char Defines a data type that can store single characters.
class Declares a class.
const Reserved for future use, not currently used.
continue Skips the rest of the current loop iteration and continues to the next iteration.
default Specifies the default case in a switch statement.
do Starts a do-while loop.
double Defines a data type that can store double-precision floating-point numbers.
else Specifies an alternative branch in an if-else statement.
enum Declares an enumeration (a special type of class with a fixed set of constants).
extends Indicates that a class inherits from another class (implements inheritance).
final Indicates that a variable, method, or class cannot be modified or extended.
finally Defines a block of code that will be executed after a try-catch block, regardless of whether an exception occurred or not.
float Defines a data type that can store single-precision floating-point numbers.
for Starts a for loop.
goto Reserved for future use, not currently used.
if Specifies a conditional statement.
implements Indicates that a class implements an interface.
import Imports packages or classes into the current source file.
instanceof Checks whether an object is an instance of a specific class or interface.
int Defines a data type that can store integer values.
interface Declares an interface (a collection of abstract methods and constants).
long Defines a data type that can store integer values with a wider range.
native Indicates that a method is implemented in native code using a language other than Java.
new Creates new objects.
package Declares a package, which is a namespace that organizes a set of related classes and interfaces.
private Specifies that an element (variable, method, or class) is accessible only within its own class.
protected Specifies that an element is accessible within its own package and by subclasses.
public Specifies that an element is accessible from any other class.
return Returns a value from a method.
short Defines a data type that can store integer values with a smaller range.
static Indicates that a variable, method, or block belongs to the class rather than any specific instance of the class.
strictfp Ensures consistent floating-point calculations across different platforms.
super Refers to the superclass of the current object.
switch Specifies a multi-way branch statement.
synchronized Controls access to shared resources in a multithreaded environment.
this Refers to the current object.
throw Throws an exception.
throws Indicates that a method may throw certain types of exceptions.
transient Specifies that a variable should not be serialized.
try Starts a block of code that will be tested for exceptions.
void Specifies that a method does not return a value.
volatile Indicates that a variable may be modified asynchronously.
while Starts a while loop.
quiz Long answers