Java Knowledge Flashcards

1
Q

Interface vs. Abstract Class

A

Definition:
An interface is a contract of methods (implicitly abstract), while an abstract class can have both abstract and concrete methods.

  • Interfaces in Java 8+ can have default and static methods.
  • An abstract class can maintain state (fields) and shared behavior.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ArrayList vs. LinkedList

A

Definition:
ArrayList is backed by a dynamic array; LinkedList is a doubly linked list.

  • ArrayList provides faster random access (O(1) for get).
  • LinkedList offers faster insertion/deletion at known positions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

final, finally, finalize

A

Definition:
- final: keyword for constants or methods that cannot be overridden.
- finally: a block that always executes after try-catch.
- finalize(): (deprecated) called by GC before object removal.

  • finalize() is seldom used; modern Java uses other cleanup strategies.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

== vs. equals()

A

Definition:
“==” checks reference equality for objects, while equals() checks logical (content) equality.

  • For primitives, == compares values directly.
  • For objects, == compares references unless overridden by equals().
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Java Streams

A

Definition:
A sequence of elements supporting functional-style operations (map, filter, reduce).

  • Can be sequential or parallel.
  • Encourages a more declarative approach to iteration.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ExecutorService

A

Definition:
Manages a pool of threads, simplifying concurrent execution of tasks.

  • Allows creation of thread pools, scheduling, and concurrency control.
  • Must be shut down to release resources.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

JVM Memory Areas

A

Definition:
Java divides memory into multiple areas (Heap, Stack, Metaspace, etc.).

  • Objects and class-level structures go on the heap/metaspace.
  • Local variables and function calls use the stack.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Garbage Collection in Java

A

Definition:
Automatic memory management that frees unused objects.

  • Various GC algorithms exist (Serial, Parallel, CMS, G1, ZGC…).
  • Tuning GC can greatly impact performance.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly