Java Keywords
Keywords, often known as reserved words in Java, are language terms used for internal operations or indicating planned actions. Consequently, these terms cannot be utilized as variable names or objects.
Reserved words are another term for Java keywords. Specific terms that serve as a code’s key are called keywords. Since Java has standardized these words, they cannot be used as class names, variables, or object names.
List of Java Keywords
1. Permits
To specify which subclasses are permitted to extend a sealed class declaration, use the Permits keyword.
2. Sealed
The sealed keyword allows one for declaring a class as “sealed,” which limits the classes that can extend it.
3. While
A while loop is started with the Java while keyword. This loop repeatedly runs a portion of the program. For variable iterations, use a while loop.
4. Volatile
The Java volatile keyword serves to signal that a variable can change asynchronously.
5. Void
The Java void keyword indicates a method with no return value.
6. Try
Initiates the code segment that will be examined for problems.
7. Transient
This indicates that the variable is not part of the object’s permanent state.
8. Throws
Indicates what errors can be raised by a method.
9. This
Refers to the object that is currently in a constructor or procedure.
10. Synchronized
In multithreaded programming, the synchronized keyword identifies critical components or procedures.
11. Switch
A statement that, in response to a test value, runs code
12. Super
A reference variable utilized to refer to parent class objects is the Java super keyword. Invoking the current parent class method is one of its uses.
13. Strictfp
To guarantee portability, a Java keyword limits the accuracy and rounding of floating-point computations.
14. Static
Java employs the static keyword to identify variables or methods as class methods. In Java, the static keyword is mostly utilized for memory management.
15. Short
To set up a variable that can store a 16-bit integer, use the Java short keyword.
16. Return
Returns control from a called method, along with a potential return value.
17. Public
Access specifiers for classes, interfaces, methods, and variables that show whether a certain item is accessible throughout the program (or when the class defining it is accessible)
18. Protected
An access specifier specifies that a variable or method can only be accessed within the class in which it is declared, its subclass, or other classes within the same package.
19. Private
An access specifier limits a method’s or variable’s access to the class in which it is declared.
20. Null
To show that a reference doesn’t relate to anything, Java uses the null keyword. The junk value is eliminated.
21. Native
Use the Java native keyword to show that a method has been incorporated into native code using JNI (Java Native Interface).
22. Instanceof
Shows whether an object follows an interface or is an instance of a particular class.
23. If
Determines whether a phrase is true or false and branches appropriately.
24. Finally
displays a try-catch chunk of code that is executed continuously.
25. final
Shows that a method won’t be overridden or that a variable has a constant value.
26. Extends
Shows that a class originates from an interface or other class.
27. Enum
An enumerated type is declared using a Java keyword. The basic class is extended via enumerations.
28. Else
Shows different branches in an if statement.
29. Double
A data type that supports floating-point numbers with 64 bits
30. Default
This specifies the standard code block found in a switch statement.
31. Char
A data type that can store unsigned 16-bit Unicode characters.
32. Catch
The catch keyword in Java is used to record exceptions that try statements throw. It can be used only after the try block.
33. Case
The Java case keyword is used with the switch statement for marking sections of text.
34. Byte
The Java byte keyword serves for declaring a variable that may store 8-bit data values.
35. Break
To break a loop or switch statement, use the Java break keyword. It interrupts the current flow of the program at the point determined.
36. Boolean
The Java boolean keyword can be utilized to declare a variable’s boolean type. It can store either True or False data.
37. Assert
Explains a predicate used in a Java application to indicate that the developer believes the assumption being is always true at that point.
38. Abstract
This suggests that a subclass will be used to further develop a class or method.
40. Package:
The Java package keyword can be utilized to declare a Java package containing the classes.
41. New
To create new objects in Java, use the new keyword.
42. long:
Using the Java long keyword, a variable that might hold a 64-bit integer is declared.
43. Interface:
The Java interface keyword acts to define an interface. It can only include abstract methods.
44. Import:
Classes and interfaces are made available and accessible within the current source code by using the Java import keyword.
45. For
To start a for loop in Java, utilize the for keyword. It is used to repeatedly execute a collection of instructions or functions when certain criteria are met. For loops are the suggested approach when there is a set number of iterations.
46. Finally
In a try-catch structure, a block of code is represented by the Java finally keyword. This block is run regardless of how the exception was handled or not.
Data Types in Java
The variation of values and sizes that a variable can store is specified by its data type. Two different types of data types exist in Java :
Primitive Data Types:
Primitive data types include boolean, char, byte, short, int, long, float, and double.
Non-primitive data types:
Non-primitive data types include classes, arrays, and interfaces.
Java Primitive Data Types
Java’s primitive data types form the basis for data manipulation. The primary data types that Java offers are as follows:
There exist eight primitive data types:
- boolean data type
- byte data type
- short data type
- int data type
- long data type
- float data type
- double data type
- char data type

| Data Type | Default Value | Default size |
| boolean | false | 1 bit |
| char | ‘\u0000’ | 2 byte |
| byte | 0 | 1 byte |
| short | 0 | 2 byte |
| Int | 0 | 4 byte |
| long | 0L | 8 byte |
| float | 0.0f | 4 byte |
| double | 0.0d | 8 byte |
Boolean Data Type
The Boolean data type only has two possible values: true and false. This data type is intended to store simple flags that represent true or false conditions.
The Boolean information The Boolean data type can store just two values: true and false. Although it provides a single piece of information, its “size” is not made explicit.
Byte Data Type
One illustration of a fundamental data type is the byte data type. It’s an 8-bit signed two’s complements integer. Its value range is between -128 and 127 (inclusive). The minimum value is -128, while the greatest value is 127. The default value is zero.
The byte data type can be used to save memory in big arrays where memory conservation is crucial. A byte saves space because it is four times smaller than an integer. It can also be utilized instead of the “int” data type.
Example: byte a = 10 and byte b = -20.
Short Data Type
Type of Short Data A preserved 16-bit two’s complement integer is the short data type. It has a value between -32,768 and 32,767 (inclusive). 32,767 is the maximum value and -32,768 is the minimum. Zero is the default value.
Similar to the byte data type, the short data type can be utilized to save memory. Short data types are two times smaller than integers.
Example: short s = 10000, short r = -5000.
Int Data Type
32-bit signed two-component integers are the standard form of integer data. The value range is between -2,147,483,648 (-2^31) and 2,147,483,647 (2^31 -1) (inclusive). The minimum value is -2,147,483,648 while the maximum value is 2,147,483,647. Zero is the default value.
Whenever there is a memory problem, the int data type generally serves as the default data type for integral numbers.
Example: int a = 100000, int b = -200000.
Long Data Type
The long data type is a 64-bit integer with two’s complement. The value range is between -9,223,372,036,854,775,808(-2^63) and 9,223,372,036,854,775,807(2^63 -1) (inclusive). The smallest amount is – 9,223,372,036,854,775,808, and the highest value is 9,223,372,036,854,775,807. The default value is zero. The long data type is used when you require a larger range of values than what int can offer.
Example: long a = 100000L, long b = -200000L.
Float Data Type
An IEEE 754 floating point data type with single precision and 32 bits is referred to as a float data type. Its range of values is limitless. If you need to conserve memory in big arrays of floating point integers, use floats rather than doubles. Cash and other exact figures should never be represented with the float data type. The default value is 0.0F.
Example: float f1 = 234.5f.
Double Data Type
The term “double data type” refers to a 64-bit IEEE 754 floating point that has double precision. Its range of values is limitless. Like float, the double data type is commonly used for decimal values. The double data type shouldn’t ever be used to represent precise values, such as cash. The default value is 0.0d.
Example: double d1 = 12.3.
Char Data Type
The char data type represents one 16-bit Unicode character. It ranges from ‘\u0000’ (or 0) to ‘\uffff’ (or 65,535 inclusive). Char data types are utilized to store characters.
For instance, char letterA = ‘A’.One illustration of a fundamental data type is the byte data type. It’s an 8-bit signed two’s complements integer. Its value range is between -128 and 127 (inclusive). The minimum value is -128, while the greatest value is 127. The default value is zero.
The byte data type can be used to save memory in big arrays where memory conservation is crucial. A byte saves space because it is four times smaller than an integer. It can also be utilized instead of the “int” data type.
Example: byte a = 10 and byte b = -20.
What is \u0000 and why does Java use two bytes for char?
he reason for this is that Java employs the Unicode coding system instead of the ASCII code system. \u0000 represents the Unicode system’s lowest range. For a more in-depth explanation of Unicode, see the following page.
Java Variables
A variable is a container that stores a value while a Java application is running. A variable is given a data type. The name of a memory region is called a variable. Three categories of variables are defined by Java: local, instance, and static. Primitive and non-primitive data types are available in Java.
Variable
The variable is the designation of a reserved memory region. Stated differently, it is the name of a location in memory. It is a mix of “vary” and “able,” indicating that its value can be modified.
Types of variables
- Local Variable: The term “local variable” refers to a variable declared within the method body. You can only utilize this variable within that method; the other functions in the class are unaware of its existence. The “static” keyword cannot be used to create local variables.
- Instance Variable: A variable provided inside the class but beyond the method body is referred to as an instance variable. It is not designated static. It is called an instance variable given that its value is unique to each instance and is not shared with other instances.
- Static variable: Static variables are those that have been declared as such. This cannot be local. A static variable can be created in a single copy and applied to every instance of the class. Static variable memory allocation only happens once, during the class’s memory load.
Unicode System
The majority of the world’s written languages may be represented by Unicode, a widely accepted character encoding.
Why is the Unicode System used by Java?
There were alternative linguistic standards prior to Unicode:
- The United States’ American Standard Code over Information Interchange (ASCII).
- ISO 8859-1 for Western European languages.
- KOI-8 in Russian.
- For Chinese, use GB18030 and BIG-5.