1. What is a practical use of a Semaphore in Java?
Semaphores manage permits. Threads acquire a permit before proceeding and release it afterward, capping concurrency to available resources.
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Stripe · Java
Practice Java questions specifically asked in Stripe interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
4
Tagged for this company + subject
Company
Stripe
View company-wise questions
Subject
Java
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Stripe Java round.
Semaphores manage permits. Threads acquire a permit before proceeding and release it afterward, capping concurrency to available resources.
For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.
Weak references allow GC to reclaim entries aggressively—good for caches with no hard retention. Soft references are less aggressively reclaimed (historically for caches, though guidance now favors explicit policies). Phantom references are for post-mortem cleanup with ReferenceQueue; you cannot get the referent.
1) Immutability: immutable objects can be shared freely—no races on state. 2) Confinement: keep mutable state confined to a single thread (e.g., ThreadLocal or task confinement) to avoid sharing. 3) Stateless functions and message passing: prefer pure functions; exchange data via queues, reducing shared mutable state. These reduce contention and simplify reasoning.
Mark sensitive or derived fields transient to omit them. For tailored behavior, implement private writeObject/readObject hooks to transform, validate, or reconstruct state.