Consider the following Spring bean:

@Component
public class TaskExecutor {

    @Value("${thread.count:10}")
    private int threadCount;
    @Value("worker.thread.name")
    private String threadNameTemplate;
    private AtomicInteger counter = new AtomicInteger();
    private ExecutorService executorService;

    @PostConstruct
    public void init() {
        ThreadFactory threadFactory = (runnable) -> new Thread(threadNameTemplate + counter.incrementAndGet());
        executorService = Executors.newFixedThreadPool(threadCount, threadFactory);
    }
}

Select the statements that are correct.

(Select all acceptable answers.)

Properties injected with @Value may, among other sources, come from system properties and JVM arguments.
As the values of threadCount and threadNameTemplate are private and have no setters, they cannot be set by Spring.
Initialization will fail because the counter and executorService fields are not managed by Spring.
If a property named "thread.count" is not made available to Spring (i.e. through property files), the value of threadCount field will be 10.
The value of the field threadNameTemplate will always be set to the same value regardless of properties provided to Spring.
   

Tags
Java Spring Configuration Public
Easy

5min

Score Distribution
Loading...
Would you like to see our other questions?

We have 500+ premium hand-crafted questions for 30+ job skills and 10+ coding language. We prefer questions with small samples of actual work over academic problems or brain teasers.

Visit our question library

Private Concierge

Send us an email with an explanation of your testing needs and a list of candidates. We will create an appropriate test, invite your candidates, review their results, and send you a detailed report.


Would you like to see our tests? The following tests contain Java Spring related questions:
On the TestDome Blog

Screening Applicants: The Good, the Bad and the Ugly

Since we’re all biased and we use incorrect proxies, why not just outsource hiring to experts or recruitment agencies? After all, they’ve been screening people for many years, so they must know how to do it right?

Not really. I was surprised to discover that many experts disagree with each other. Everybody praises their pet method and criticizes the others. Many of these methods look legitimate, but are based on...