Skip to Content
Course content

319: Practice Exercise: Timed Mock Assessment on Core Java

Click on the "Edit" button in the top corner of the screen to edit your slide content.

By the time you've reached this point in the course, you know the syntax and the API. But there is a massive difference between knowing how a HashMap works in a vacuum and implementing a solution while a timer is ticking down in the corner of your screen. Most developers I've mentored don't fail mock assessments because they forgot how to write a try-catch block; they fail because they approach the test like they're building a production system for a Fortune 500 company rather than solving a discrete problem.

The Trap of Over-Engineering

I often see students tackle a prompt—say, "Create a system to track employee payroll"—and immediately start sketching out a PayrollStrategy interface, an AbstractEmployee class, and perhaps a PayrollFactory. On a real project, I'd applaud that foresight. In a timed assessment, it's a death sentence. You spend forty minutes building a flexible architecture for a problem that only requires a few lines of logic, and then you run out of time before you actually implement the business rule.

Contrast that with the pragmatic approach. If the task asks you to calculate the total pay for a list of employees, start with a simple loop or a Stream. Use a concrete class. Get the logic passing the test cases first. If you have twenty minutes left at the end, then you can refactor into a more elegant design. I've seen plenty of candidates get zero points for a "perfectly architected" system that didn't actually run, while the person who wrote a slightly messy for loop got full marks because their code actually produced the correct output.

// The "Architecture First" mistake (Too much for a 30-minute test)
public interface PaymentCalculator {
    double calculate(Employee e);
}
public class SalariedCalculator implements PaymentCalculator { ... }
public class HourlyCalculator implements PaymentCalculator { ... }
// ... and three more classes before you even hit 'main'

Instead, do this:

// The "Pragmatic First" approach
public double calculateTotalPayroll(List<Employee> employees) {
    return employees.stream()
                    .mapToDouble(Employee::getSalary)
                    .sum();
}

When the Clock Becomes Your Enemy

The second big mistake is the "Rabbit Hole." You hit a bug in your logic, and you spend fifteen minutes staring at a single line of code, convinced that you've found a deep, systemic flaw. You stop moving. In a mock assessment, your goal isn't perfection; it's point maximization. If you're stuck on a complex sorting algorithm that's eating your time, comment out the broken part, write a "TODO" note, and move to the next requirement. I can give partial credit for a nearly-finished feature, but I can't give any credit for a blank screen.

The trade-off here is between rigor and velocity. In your daily job, rigor wins. In an assessment, velocity is the priority. You want to map out the "Minimum Viable Solution" for every problem on the test before you spend more than five minutes polishing any single method. If the prompt asks for three features, and you spend all your time making feature one "bulletproof," you've essentially decided to fail the other two-thirds of the test.




📋 Practical Task

The High-Pressure Transaction Analysis Challenge

You are tasked with simulating a real-world technical assessment. Set a timer for 45 minutes. You must implement a TransactionAnalyzer class that processes a list of Transaction objects (each containing a customerId, amount, and category).

Requirements:

  • Implement a method getTopCustomer(List<Transaction> txns) that returns the ID of the customer who spent the most money across all categories.
  • Implement a method getCategoryTotals(List<Transaction> txns) that returns a Map<String, Double> containing the total spend per category.
  • Handle potential null lists or empty lists by returning appropriate defaults (e.g., null or an empty map) without throwing an exception.

Constraint: Do not create any unnecessary interfaces or design patterns. Focus on using the Java Collections Framework and Streams to achieve the result as concisely as possible. Your goal is a working, bug-free implementation within the time limit.

Rating
0 0

There are no comments for now.

to be the first to leave a comment.