Keywords and Terminolgies
Class & Object
class
: Defines a class.
interface
: Declares an interface (a contract for classes).
object
: An instance of a class.
new
: Instantiates a new object.
Modifiers
public
/ private
/ protected
: Access control modifiers (already discussed).
static
: Indicates a field or method belongs to the class rather than instances, is shared across all instances of a class.
final
: Used to declare constants, prevent method overriding, or inheritance, A final method cannot be overridden by subclasses, A final class cannot be inherited.
abstract
: Used to declare incomplete methods or classes that must be extended.
Inheritance & Polymorphism
extends
: A class inherits another class.
implements
: A class implements an interface.
super
: Refers to the parent class’s members.
this
: Refers to the current instance of the class.
Control Flow
if
/ else
/ switch
: Conditional statements.
for
/ while
/ do-while
: Looping constructs.
break
/ continue
: Control loop execution.
return
: Exits from a method and optionally returns a value.
Exception Handling
try
/ catch
/ finally
: Handle exceptions.
throw
/ throws
: Raise exceptions.
assert
: Check assumptions during development.
Memory Management/Threada
new
: Allocates memory for an object.
null
: A reference that points to no object.
synchronized
: Used to control access to methods or blocks in a multithreaded environment.
volatile
: Ensures visibility of changes to variables across threads.
transient
: Prevents serialization of a field.
Types
void
: Specifies that a method does not return a value.
primitive types
: int
, float
, char
, boolean
, etc.
instanceof
: Tests if an object is of a particular type.
Others
enum
: Declares an enumeration, a special type with predefined constant values.
package
: Defines a package (namespace) for classes.
import
: Brings other classes or packages into the current class.
default
: Provides default implementations in interfaces or switch statements.
native
: Declares methods implemented in native code (outside Java).
strictfp
: Ensures consistent floating-point calculations across platforms.
const
/ goto
: Reserved keywords (not used in Java).
November 24, 2024
October 25, 2024
GitHub
Back to top