abstract | A non-access modifier that is used on classes and methods to imply that it would be implemented later in the program. | abstract class A
{ …
abstract void methodA();
}
class B extends A
{
@Override
void methodA()
{ … }
}
 You can also try this code with Online Java Compiler Run Code |
assert | It describes a true-false statement to indicate that the user wants the result to be true. | assert expression1 : expression2;
 You can also try this code with Online Java Compiler Run Code |
boolean | A primitive data type that declares a variable to hold two values - true and false | boolean x = true;
 You can also try this code with Online Java Compiler Run Code |
break | A control statement used to break out of loops and switch case blocks. | while(condition)
{
if (condition)
break;
}
 You can also try this code with Online Java Compiler Run Code |
byte | It is a signed 8-bit primitive data type in Java. Range: -128 to 127 | byte a =1;
 You can also try this code with Online Java Compiler Run Code |
char | A primitive data type that is used to declare a character variable. | char ch = ‘a’;
 You can also try this code with Online Java Compiler Run Code |
case | This is used in switch-case statements to execute blocks of code based on specific events/conditions. | switch(exp)
{
case x: …
break;
.
.
default: …
}
 You can also try this code with Online Java Compiler Run Code |
catch | It is used to catch the exceptions generated by try statements. | try
{ … }
catch (Exception e)
{ … }
 You can also try this code with Online Java Compiler Run Code |
class | To define and declare a class in Java. | class Class_name
{ … }
 You can also try this code with Online Java Compiler Run Code |
continue | A control statement that is used to skip the current iteration and continue to the next. | while(condition)
{
if (condition)
continue;
}
 You can also try this code with Online Java Compiler Run Code |
default | - An access modifier that restricts the access of its members outside the declared package.
- It specifies the default block of code in a switch statement.
| class A
{
default void methodA( ) { }
}
switch(exp)
{
case x: …
break;
default: …
}
 You can also try this code with Online Java Compiler Run Code |
do | It is used to start a do-while loop. | do { … }
while (condition);
 You can also try this code with Online Java Compiler Run Code |
double | A primitive data type that declares variables to store 64-bit floating point numbers. | double x = 23.46287573734;
 You can also try this code with Online Java Compiler Run Code |
else | It is used to declare an alternate set of codes for an if statement. | if (condition)
{ … }
else { … }
 You can also try this code with Online Java Compiler Run Code |
enum | A keyword used to declare an enumerated data type that represents a group of constants. | enum enum_name
{ … ,
constant_n; }
 You can also try this code with Online Java Compiler Run Code |
extends | It is used to indicate that a class is derived from another class. | class A { … }
class B extends A { … }
 You can also try this code with Online Java Compiler Run Code |
final | A non-access modifier which indicates that the contents of its variable, class or method is constant and final. | final variable1 = 20;
 You can also try this code with Online Java Compiler Run Code |
finally | It is used with try-catch statements to deal with exceptions. It holds the block of code that is executed irrespective of whether an exception exists or not. | try
{ … }
catch (Exception e)
{ … }
finally
{ … }
 You can also try this code with Online Java Compiler Run Code |
float | A primitive data type that declares a variable to hold 32-bit floating-point numbers. | float x = 234.34;
 You can also try this code with Online Java Compiler Run Code |
for | It is used to start a for loop. | for ( … ; … ; … )
{ … }
 You can also try this code with Online Java Compiler Run Code |
if | It starts an if conditional statement. | if (condition)
{ … }
 You can also try this code with Online Java Compiler Run Code |
implements | It indicates that the class implements an interface. | interface A
{
public void methodA();
}
class B implements A
{
@Override
void methodA()
{ … }
}
 You can also try this code with Online Java Compiler Run Code |
import | It is used to import a package or class. | import java.util.*;
 You can also try this code with Online Java Compiler Run Code |
instanceof | It is used to check whether an object is an instance of a specific class or if it implements an interface. | object_name instanceof class_name;
 You can also try this code with Online Java Compiler Run Code |
int | A primitive data type that can hold integers in the range -2147483648 to 2147483647 | int x = -3825;
 You can also try this code with Online Java Compiler Run Code |
interface | It is used to declare a class for only abstract methods. | interface Interface_name
{
void methodA( );
}
 You can also try this code with Online Java Compiler Run Code |
long | A primitive data type capable of holding very large numbers. (64-bit integers) | long x = 4354748364448;
 You can also try this code with Online Java Compiler Run Code |
native | It is used to indicate that the method is implemented in a language other than Java (native platform-specific code ) | public native void method();
 You can also try this code with Online Java Compiler Run Code |
new | It is used to create new objects of a class or an array. | Class_name obj = new Class_name();
 You can also try this code with Online Java Compiler Run Codeint[ ] arr = new int[size];
 You can also try this code with Online Java Compiler Run Code |
package | To declare a new package. | package package_name;
 You can also try this code with Online Java Compiler Run Code |
private | An access modifier that allows access of its members only within the declared class. | private void method() { … }
 You can also try this code with Online Java Compiler Run Code |
protected | An access modifier that allows access of its members within the package and all of its subclasses. | protected void methodA() { … }
 You can also try this code with Online Java Compiler Run Code |
public | An access modifier that allows access of its members to the entire Java universe. | public void methodA() { … }
 You can also try this code with Online Java Compiler Run Code |
return | It causes the control to return from a called method back to the calling method. | public void methodB()
{ …
return;
}
public void methodA()
{ …
methodB();
}
 You can also try this code with Online Java Compiler Run Code |
short | A data type that holds 16-bit integers. | short x = 21;
 You can also try this code with Online Java Compiler Run Code |
static | A non-access modifier which indicates that it can be accessed without the creation of an object. | public static void main() { … }
 You can also try this code with Online Java Compiler Run Code |
strictfp | It restricts the precision and truncation of floating-point calculations to ensure portability. | public strictpf class A { … }
 You can also try this code with Online Java Compiler Run Code |
super | It is used to refer to the object of a parent class. | super(argument_list);
 You can also try this code with Online Java Compiler Run Code |
switch | It is used to create a multiway branch statement. | switch(exp)
{
case x: …
break;
…
default: …
}
 You can also try this code with Online Java Compiler Run Code |
synchronised | A non-access modifier which tells that the critical sections of a multithreaded code should be executed one thread at a time. | public synchronised void methodA() { … }
 You can also try this code with Online Java Compiler Run Code |
this | It is used to reference the current object variable or method. this() can be used to invoke the current class constructor. | class A
{
public int a;
public A( int b)
{
this.a = b;
}
}
 You can also try this code with Online Java Compiler Run Code |
throw | It is used to throw a declared exception and create a custom error. | throw new exception_type(message);
 You can also try this code with Online Java Compiler Run Code |
throws | throws is used to indicate the exception type that may be thrown by a method. | void methodA() throws exception_type
{ … }
 You can also try this code with Online Java Compiler Run Code |
transient | A non-access modifier which specifies that an attribute is not part of an object's persistent state. | private transient int variable_name;
|
try | It is used to start a try-catch block that handles exceptions. | try
{ … }
catch (Exception e)
{ … }
 You can also try this code with Online Java Compiler Run Code |
void | It is used to declare that a method does not return any value. | public static void main()
 You can also try this code with Online Java Compiler Run Code |
volatile | Volatile specifies that a variable is asynchronously modified by concurrently running threads. | static volatile int var_name = 5;
 You can also try this code with Online Java Compiler Run Code |
while | It is used to start a while loop. | while(condition)
{ … }
 You can also try this code with Online Java Compiler Run Code |