1/48
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
class
defines a new class
extends
used for inheritance
implements
used when a class implements an interface
new
creates an object
this
refers to the current object
super
refers to the superclass
throw
manually throws an exception
throws
declares that a method may throw exceptions
static
belongs to the class, not the object
final
value cannot be changed / class cannot be extended / method cannot be overridden
public / private / protected
access modifiers
return
sends a value back
abstract
marks abstract class/method
interface
declares an interface
import
imports another package or class
How does method overloading work in Java?
Overloading = same method name, different parameters (different type or count).
Resolved at compile time
How does method overriding work in Java?
Overriding = same method name + same parameters in a subclass.
Requires inheritance.
Uses runtime dynamic dispatch.
What is variable shadowing?
Shadowing happens when a local variable or parameter has the same name as a field, hiding the field.
Use this.x to refer to the field.
How does inheritance work in Java?
A subclass extends a superclass, meaning it:
gains its fields and methods
can override methods
can call super() to use parent constructors
supports code reuse and polymorphism
What is the difference between an abstract class and an interface?
Abstract Class:
Can have fields, concrete methods, and abstract methods
A class can extend only one abstract class
Interface:
Contains abstract methods (and default/static methods)
No instance fields
A class can implement many interfaces
When would you use an abstract class?
Use an abstract class when:
Objects share state (fields)
You need some shared code + some abstract methods
You want to enforce “is-a” hierarchy with shared functionality
When would you use an interface?
Use an interface when:
You only need to define capabilities / behaviors
Multiple unrelated classes should share the same behavior
You want multiple inheritance of type
JFrame
main window
JPanel
container
JButton
clickable button
JLabel
text label
JTextField
text input box
JOptionPane
popup alert/message input
Class name (uml)
class declaration
+ public / - private / # protected symbols (uml)
access modifiers
Fields (with type) (uml)
instance variables
Methods (with return types) (uml)
methods
Italic method/class names (uml)
abstract
Arrow with hollow triangle (uml)
inheritance (extends)
Dotted arrow (uml)
interface (implements)
Diamond (uml)
composition/aggregation depending on fullness
Class declaration (convert into uml)
class box
Fields (convert into uml)
list under "attributes"
Methods (convert into uml)
list under "operations"
Access modifiers (convert into uml)
+ (public), - (private), # (protected)
Abstract methods (convert into uml)
italic
Inheritance (convert into uml)
arrow to parent
Interfaces (convert into uml)
dotted arrow
git branch branchName
create a branch
git checkout branchName
switch to branch
git merge branchName
merge into current branch
git branches
Used to work on new features without touching main
What is a pull request (PR) and how do you create one?
A pull request is a request to merge changes from your branch into the main branch.
Steps for pull request
Create a new branch
Commit your changes
Push the branch: git push -u origin branchName
Open GitHub → click New Pull Request
Compare your branch → main
Add description
Submit PR
Reviewer approves and merges