WORKBOOK · FREE SAMPLE BELOW
Java interview practice workbook
Ten original coding tasks covering methods, arrays, object behaviour, collections and input handling. Work through each task, then compare with a complete Java 17 solution.
The team will confirm price, access and delivery before purchase.
Who it is for
Learners who can run a Java class and want to explain their decisions in an interview.
Attempt each task before looking at its answer. State the assumptions, predict the result and test one boundary case. A working answer is the start: explain why it behaves correctly and what you would change if the requirements changed.
This is a self-study resource. It is not an official exam, a qualification or a promise of employment. If you need guided classes, ask the team about the relevant course separately.
What is included
- 10 original coding tasks
- Complete runnable Java 17 solutions
- Expected output and review points
- A self-assessment rubric and interview follow-up prompts
Assess each task against its result, edge cases, explanation and readability. Record a mistake and retry the task later without opening the solution.
Try two free sample tasks
These tasks show the format and level of the full workbook. Read the prompt first; open the answer only after making your own attempt.
1. Sum the even values
Write sumEven(int[] values). Return the sum of even values, including zero and negative even numbers. Return zero for an empty array. Demonstrate it with {3, 6, -2, 0, 5}.
Compare the answer and review points
public class Main {
static int sumEven(int[] values) {
int sum = 0;
for (int value : values) if (value % 2 == 0) sum += value;
return sum;
}
public static void main(String[] args) {
System.out.println(sumEven(new int[]{3, 6, -2, 0, 5}));
System.out.println(sumEven(new int[]{}));
}
}Expected result
4
0- Handles negative even numbers
- Returns zero for empty input
- Keeps the accumulator outside the loop
2. Find the first largest-mark position
Return the index of the first largest mark, or -1 for an empty array. For {70, 95, 95, 82}, the answer must be 1 rather than 2. Do not sort or mutate the array.
Compare the answer and review points
public class Main {
static int firstLargest(int[] marks) {
if (marks.length == 0) return -1;
int best = 0;
for (int i = 1; i < marks.length; i++) {
if (marks[i] > marks[best]) best = i;
}
return best;
}
public static void main(String[] args) {
System.out.println(firstLargest(new int[]{70, 95, 95, 82}));
System.out.println(firstLargest(new int[]{}));
}
}Expected result
1
-1- Uses > so a tie preserves the first position
- Handles empty input
- Does not mutate or sort the input
Ready for the full workbook?
Ask the Forsk team to confirm the current price and the way the workbook will be delivered. Mention the workbook name so your enquiry reaches the right resource.
Ask about this workbook →Prefer another channel? Contact Forsk.
