How does testing a CNN work after training?
The last layer of your neural network is a sigmoid function. During training, all the parameters are being learned. Hence, given a new picture, we can compute a value that is between $0$ and $1$ from the sigmoid function (which is used as a model of probability) to let us know the desired probability.

For multi-class classification problem. A softmax layer is used instead.