Java final quiz

  • Admin
  • 1 min read

Ten mixed questions covering the whole Java track, from compilation to the capstone.

Java

Java final quiz

10 questions, instant feedback

Question 1 of 10
Question 1 of 10 What does the JVM provide that makes Java portable?
Why this is the answer

javac produces bytecode; each platform's JVM executes it, so the same class file runs everywhere a JVM exists.

Question 2 of 10
Question 2 of 10 What is the value of 10 % 3?
Why this is the answer

The remainder operator returns what is left after division: 10 = 3 * 3 + 1.

Question 3 of 10
Question 3 of 10 Which loop guarantees the body runs at least once?
Why this is the answer

do-while checks its condition after the body, so the first pass always happens.

Question 4 of 10
Question 4 of 10 What is the difference between == and equals for objects?
Why this is the answer

== asks whether two variables point at the same object. equals is a method that classes override to compare state.

Question 5 of 10
Question 5 of 10 Which statement about interfaces is correct?
Why this is the answer

A class implements any number of interfaces but extends only one class.

Question 6 of 10
Question 6 of 10 What happens when an array index is out of bounds?
Why this is the answer

Java checks bounds at runtime and throws, rather than reading adjacent memory.

Question 7 of 10
Question 7 of 10 Why override hashCode with equals?
Why this is the answer

HashMap looks up by hash first. Equal objects with different hashes can be stored twice and never found.

Question 8 of 10
Question 8 of 10 What does a JUnit @Test method need?
Why this is the answer

JUnit 4 requires public void methods. JUnit 5 relaxes the visibility to package-private.

Question 9 of 10
Question 9 of 10 What is a stream in Java?
Why this is the answer

Streams describe a sequence of operations such as filter and map, evaluated when a terminal operation runs.

Question 10 of 10
Question 10 of 10 Which is the better reason to use Maven or Gradle?
Why this is the answer

javac compiles. A build tool resolves libraries, runs tests and produces a reproducible artefact.

Your answers stay in this browser. Nothing is sent to a server.