A police spokesman said the boy had a loaded semiautomatic handgun and told police he needed the gun for protection.