Reserved Keywords Flashcards
abstract
a non-access modifer. Used for classes and methods: an abstract class cannot be used to create objects -> (Must be inherited from another class). An abstract method can only be used in an abstract class, and it does not have a body. The body is provided by the subclass.
assert
For debugging -> used to verify that a certain assumption about the program is true. (assert (i == 0))
break
used to break out of a loop or switch block
case
Marks a block of code in switch statement
catch
Catches exceptions generated by try statements
class
Defines a class
continue
Continues to next iteration of a loop
final
Defines a constant -> value is non-changeable, impossible to inherit or override
default
Specifies the default block of code in a switch
statement
do
Used together with while to create a do-while loop
else
used in conditional statements
exports
Exports a package with a module
extends
Extend from parent class
finally
Used with exceptions, block of code that will be executed no matter if there is an exception or not
implements
implements an interface
import
used to import a package, class or interface
instanceof
Checks whether an object is an instance of a specific class or an interface
native
Specifies that a method is not implemented in the same Java source file (but in another language)
new
Creates new objects
module
Declares a module
package
declares a package (Basically a folder used to group classes)
private
access modifier used for attributes, methods and constructors, making them only accessible within the declared class
protected
an access modifier used for attributes methods and constructors, making them accessible in the same package and subclasses
public
access modifier used for classes, attributes, methods and constructors making them accessible by any other class
requires
Specifies required libraries inside a module
return
Finished the execution of a method, and can be used to return a value from a method
static
non-access modifier used for methods and attributes, static methods/attributes can be accessed without creating an object of a class
strictfp
restrict the precision and rouding of floating point calculations
super
refers to superclass (parent) objects
switch
selects one of many code blocks to be executed
synchronized
a non access modifier, rwhich specifies that methods can only be accessed by one thread at a time
this
refers to the current object in a method or constructor
throw
creates a custom error
throws
indicates what exceptions may be thrown by a method
transient
a non-access modifer which specifies that an attribute is not part of an object’s persistent state
try
creates a try/catch statement
void
specifies that a method should not have a return value
volatile
indicates that an attribute is not cached thread-locally, and is always read from the “main memory”