Hero Image
- Mihai Surdeanu

(#7) Tricky Java Questions for Interviews

Motto: Keep in mind - try to reduce memory consumption of your application!

Q1: Think about some real use-cases when a blocking queue can be used in practice. Can you give one example of implementation for a blocking queue?

Q2: In which situation a CopyOnWriteArrayList is preferred against another concurrent implementation of a list?

Q3: Reduce memory footprint for the following class:

public class MyPersonalCar {
    private Boolean inService = false;
    private long age = 10; // in years
    private LocalDate acquisitionDate = LocalDate.of(2010, 11, 23);
}

By the way, can you specify how many bytes were saved after implementing all changes suggested?

Other Related Posts:

Microbenchmarking with Java

Microbenchmarking with Java

Hello guys,

Today, we are going to continue the series of articles about Java ecosystem. More specific, today, we are going to talk about JMH (Java Microbenchmark Harness).

2nd Apr 2022 - Mihai Surdeanu