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.

21 Easy Collections Backend

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

Short take Full answer on next page

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
23 Easy Equals and hashCode Backend

Why must equals and hashCode be overridden together?

Short take Full answer on next page

Simple meaning

HashMap and HashSet place objects into buckets using hashCode, then confirm equality with equals.

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 Full answer on next page

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 Full answer on next page

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 Full answer on next page

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 Full answer on next page

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
38 Easy SQL Backend

What is a foreign key and why do we use it?

Short take Full answer on next page

Simple meaning

A foreign key is a column, or set of columns, that must match a unique key in another table.

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