Java Keywords

Published by Admin on

Java Keywords are special words that serve as the key to the code. These are predefined words by Java. The java keywords is also known as reserved words.

List of Java Keywords:-

abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile

All Java Keywords With Description:-

KeywordKeyword Description
abstract“abstract keyword” is A non-access modifier. This Keyword Used for classes and methods. abstract class cannot be used to create objects. abstract method can only used in an abstract class, and it does not have a body.
assert“assert keyword” use For debugging.
boolean“boolean data type” that can only store true and false values
break“break keyword” use for Breaks out of a loop or a switch block
byte“byte data type” is primitive data type. Its value-range between -128 to 127
case“case keyword” Marks a block of code in switch statements
catch“catch keyword” use for Catches exceptions generated by try statements
char“char data type” store a single character
class“class keyword” Defines a class
continue“continue keyword” use Continues to the next iteration of a loop
const“condt keyword” Defines a constant. Not in use – use final instead
default“default keyword” Specifies the default block of code in a switch statement
doUsed to create a do-while loop
double“double data type” that can store whole numbers from 1.7e−308 to 1.7e+308
else“else keyword” Used in conditional statements
enum“enum keyword” Declares an enumerated (unchangeable) type
extends“extends keyword” use for Extends a class (indicates that a class is inherited from another class)
final“final keyword” is non-access modifier used for classes, attributes and methods, which makes them non-changeable (impossible to inherit or override)
finally“finally keyword” Use with exceptions, a block of code that will be executed no matter if there is an exception or not
float“float data type” store whole numbers from 3.4e−038 to 3.4e+038
for“for keyword” use for Create a for loop
gotoNot in use, and has no function
if“if keyword” Makes a conditional statement
implements“implements keyword” Implements an interface
importUsed to import a package, class or interface
instanceofChecks whether an object is an instance of a specific class or an interface
int“int data type” is primitive data type. Its value-range between -2147483648 to 2147483647.
interface“interface keyword” Use to declare a special type of class that only contains abstract methods
long“long data type” is primitive data type. Its value-range between -9223372036854775808 to 9223372036854775808
module“module keyword” Declares a module. New in Java 9
native“native keyword” Specifies that a method is not implemented in the same Java source file (but in another language)
new“new keyword” use for Creates new objects
packageDeclares a package
private“private access modifier” use for attributes, methods and constructors, making them only accessible within the declared class
protected“protected access modifier” use for attributes, methods and constructors, making them accessible in the same package and subclasses
public“public access modifier” use for classes, attributes, methods and constructors, making them accessible by any other class
requires“requires keyword” Specifies required libraries inside a module. New in Java 9
return“return keyword” use for Finished the execution of a method, and can be used to return a value from a method
short“short data type” is primitive data type. Its value-range between -32768 to 32767
static“static non-access modifier” use for methods and attributes. Static methods or attributes can be accessed without creating an object of a class
strictfp“strictfp keyword” use to Restrict the precision and rounding of floating point calculations
super“super keyword” Refers to superclass (parent) objects
switch“switch keyword” use for Selects one of many code blocks to be executed
synchronized“synchronized non-access modifier”, which specifies that methods can only be accessed by one thread at a time
this“this keyword” Refers to the current object in a method or constructor
throw“throw keyword” use for Creates a custom error
throws“throws keyword” Indicates what exceptions may be thrown by a method
transient“transient non-accesss modifier”, which specifies that an attribute is not part of an object’s persistent state
try“try keyword” use for Creates a try{}catch{} statement
vardeclares a variable. New in Java 10
void“void keyword” Specifies a method should not have a return value
volatile“volatile keyword” is attribute is not cached thread-locally, and is always read from the “main memory”
while“while keyword” use for Creates a while loop

Question :-

  • What is Use of short keyword?
  • What is static in java?
  • Where we can use static keyword?
  • What is static variable in java?
  • What is static method in java?
  • What is Final Keyword in Java with Examples?


0 Comments

Leave a Reply

LinkedIn
LinkedIn
Share
Instagram
Follow by Email
YouTube
YouTube
Telegram
RSS