Backend track

Java interview questions for freshers

Panel-ready Java Specialist questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.

226 Qs
21 Easy Collections Backend

What is a fail-fast iterator versus a fail-safe iterator?

Short take

Simple meaning

A fail-fast iterator, like ArrayList's, throws ConcurrentModificationException if the collection is structurally changed during iteration, except through the iterator itself.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
29 Easy Exceptions Backend

What problem does try-with-resources solve?

Short take

Simple meaning

It auto-closes AutoCloseable resources such as streams and JDBC connections when the block exits, even on exception.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
33 Easy Concurrency Backend

What is a race condition? Give a Java example.

Short take

Simple meaning

A race happens when two threads read and write shared state with no happens-before, so the result depends on timing.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
34 Easy Concurrency Backend

What does the synchronized keyword actually do?

Short take

Simple meaning

It acquires an intrinsic lock on an object before entering the block or method and releases it on exit.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
36 Easy Concurrency Backend

What is a deadlock, in one interview story?

Short take

Simple meaning

Thread A holds lock L1 and waits for L2, while thread B holds L2 and waits for L1, so both wait forever.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
Prev Page 2 of 4 Next
Chat with us