Master Java Programming with 50 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.
The Java Virtual Machine (JVM) is an abstract computing machine that executes Java bytecode. It provides platform independence by translating bytecode into native machine instructions at runtime, enabling the "Write Once, Run Anywhere" principle.
JDK (Java Development Kit) includes tools for developing Java programs.
JRE (Java Runtime Environment) provides libraries and JVM to run Java applications.
JVM (Java Virtual Machine) executes the bytecode. Relationship: JDK ⊃ JRE ⊃ JVM.
Encapsulation – bundling data and methods, restricting direct accessInheritance – a class derives from another classPolymorphism – one interface, many implementationsAbstraction – hiding complex details, showing only essentials
Encapsulation is the practice of keeping fields private and providing access through public getter and setter methods. This protects the internal state of an object and enforces data hiding.
Example: private int age; public int getAge() { return age; }
Inheritance allows a class to acquire properties and methods of another class using the extends keyword. Java supports single inheritance for classes.
Example: class Dog extends Animal { }
Polymorphism lets objects take many forms.
Compile-time (method overloading): same method name, different parameters.
Runtime (method overriding): subclass provides its own implementation of a parent method. Resolved via dynamic method dispatch.
Abstraction hides implementation details and shows only functionality. Achieved through:
Abstract classes – declared with abstract keyword, can have both abstract and concrete methodsInterfaces – define a contract of methods a class must implement
Abstract class: can have constructors, instance variables, and both abstract and concrete methods. Use extends.
Interface: all methods are implicitly public abstract (before Java 8). Supports multiple inheritance. Use implements. Since Java 8, interfaces can have default and static methods.
Java has four access modifiers:public – accessible from everywhereprotected – accessible within the same package and subclassesdefault (no keyword) – accessible only within the same packageprivate – accessible only within the declaring class
The static keyword means the member belongs to the class rather than an instance.static variables are shared across all instancesstatic methods can be called without creating an objectstatic blocks run once when the class is loadedExample: Math.sqrt(25)
final has three uses:Variable: value cannot be changed (constant)Method: cannot be overridden by subclassesClass: cannot be extendedExample: final int MAX = 100;
A constructor is a special method called when an object is created. It has the same name as the class and no return type.
Java provides a default no-arg constructor if none is defined.
Example: public MyClass(int x) { this.x = x; }
Flashcards
Flip to reveal
Focus Mode
Spaced repetition
Multiple Choice
Test your knowledge
Type Answer
Active recall
Learn Mode
Multi-round mastery
Match Game
Memory challenge