This could be solved via CSS as well. Just set up declarations for the special cases where there is overlap between categories:
.category-cars { background-color: #f00; }
.category-bikes,
.category-cars.category-bikes { background-color: #0f0; }
This will give any posts that are in both bikes and cars the same background color as those used in the bikes category.