What are Java Keywords and reserved words?

Last updated on Jun 17,2021 12.6K Views
A technophile with a passion for unraveling the intricate tapestry of the... A technophile with a passion for unraveling the intricate tapestry of the tech world. I've spent over a decade exploring the fascinating world of...

What are Java Keywords and reserved words?

edureka.co

Keywords are predefined which have a unique meaning and functionality in Java programming language. These keywords are also known as reserved keywords which mean they cannot be used as a variable name, class, method or any other identifier. There are 57 reserved keywords in Java. Meanwhile, in this huge list of java keywords, there are some which are not used anymore and few versions do not support a tiny number of keywords.

Let’s dig deeper and understand these Java keywords in-depth.

Keywords in JavaDescription

abstract

A class that is declared with abstract keyword, is known as abstract class in java. It can have abstract and non-abstract methods (method with body).

continue

It is is allowed only inside a loop body. When continue executes, the current iteration of the loop body terminates, and execution continues with the next iteration of the loop.

for

For is used  for looping. It involves initialization, a boolean expression, and incrementation/decrementation. It supports repeated execution of a statement or block of statements that is controlled by an iterable expression.

new

used to create an instance of a class, or an object.

switch

Used as a statement which executes when it matches to a specific case.

assert

Assert keyword is added in 1.4 version. It describes a predicate (true-false statement), to let developers think that it’s always true. If an assertion is false at run-time, it causes execution to abort.

default

Used in a switch statement to execute a block of code in the loop.

goto

goto has no function and it is no more supported in Java programming.

package

package is a mechanism of grouping similar type of classes, interfaces, and sub-classes collectively based on functionality.

synchronized

Synchronized blocks in Java are marked with the Synchronized keyword. This block in Java is synchronized on some object. All blocks that are synchronized on the same object can only have one thread executing inside them at a time.

boolean

boolean can hold true or false value only.

do

It is used in control statements. The Java do-while loop is used to iterate a set of statements until the given condition is satisfied.

if

If statement is used to test an expression and execute certain statements accordingly. It is also used to create an if-else statement in java.

private

Private is an access modifier in java, where the methods or data members that are declared as private are only accessible within the class in which they are declared.

this

this keyword in Java represents the current instance of a class. It is mainly used to access other members of the same class.

break

The break statement is allowed only inside a loop body. When break executes, the loop terminates.

double

It declares a variable that can hold 64-bit double floating-point numbers.

implements

used by a class to implements an interface.

protected

The methods or data members that are declared as private are only accessible within the class in which they are declared.

throw

used to create and throw an exception.

byte

It is used to declare a field which can hold 8-bit data values.

else

It is used to implement a condition alternate to if condition.

import

Used in the beginning which refers to other classes

public

Classes, methods or data members which are declared as public are accessible anywhere throughout the program. There is no restriction on the scope of public data members.

throws

Used in method declarations which specifies exceptions that can’t be handled within the method.

case

used in the switch statements which can be labeled with one or more case

enum

Enum is added in 5.0 version.

instanceof

It evaluates to true if and only if the runtime type of the object is compatible with the class or interface.

return

Used to finish the execution of a method. It returns the value required by the method.

transient

It declares an instance field which is not a part of the default serialized form of an object.

catch

Statements in the catch block specify the exceptions generated by try block.

extends

Merely indicates that a class has extended its immediate class.

int

A data type that holds 32 bit signed integer.

short

A data type that holds a 16-bit integer.

try

It tests a block of code for exceptions.

char

It is a data type that can hold a 16-bit unsigned integer.

final

Once a certain entity is defined, it cannot be changed nor derived from later.

interface

Interface in Java refers to the abstract data types. They allow Java collections to be manipulated independently from the details of their representation.

static

static keyword is mainly used for memory management. It can be used with variables, methods, blocks and nested classes

void

It returns a null value for a method.

class

It creates a new class in Java which is a blueprint from which an object is created.

finally

It specifies that a block of code under exception handling always gets executed.

long

Data type holding a 64 bit integer.

strictfp

strictfp keyword is added in 1.2 version.

volatile

Specifies or indicates that a variable might change asynchronously.

const

This const java keyword is no more used.

float

A data type holding a 32-bit floating point number.

native

It specifies that a method declaration has tobe done from platform-specific(native) code.

super

super keyword refers to the members such as variable,method and constructor of of immediate super class.

while

It is used to create while loop.The Java while loop is used to iterate a part of the program again and again. If the number of iteration is not fixed, then you can use while loop.

With this, we come to the end of this “java keywords” article. I hope you found it informative. If you wish to learn more, you can check out our other  Java Blogs as well.

Now that you have understood basics of Java, check out the Java Certification Course by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. Edureka’s Java J2EE and SOA training and certification course is designed for students and professionals who want to be a Java Developer. The course is designed to give you a head start into Java programming and train you for both core and advanced Java concepts along with various Java frameworks like Hibernate & Spring.

Got a question for us? Please mention it in the comments section of this “Java keywords” blog and we will get back to you as soon as possible.

Upcoming Batches For Java Course Online
Course NameDateDetails
Java Course Online

Class Starts on 7th December,2024

7th December

SAT&SUN (Weekend Batch)
View Details
BROWSE COURSES