CORRE[C]T: [C]ardinality

Many programmers aren’t so hot at counting, especially past ten when our fingers can no longer assist us. Answer the following question quickly and off the top of your head, without benefit of fingers, paper, or Google:

You have to erect a number of fence sections to cover a straight line 12 meters long. Each section of fencing covers 3 meters, and each end of a section must be held up with a fence post:

images/correct/fence-single.png

How many fence posts do you need?

If you’re like most of us, you probably offered an answer in short order, and it’s probably incorrect. Think again. Then take a look at the following figure for the answer. The errors ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.