Yeah you can (depends on your motherboard being able to support 24GB). You'll likely see that your slots are colour coded with 2 being one colour and the other 2 being another, if this isn't the case you should be able to see letters A or B printed on the motherboard next to the slots to indicate which slot corresponds to the other.
So just make sure you place the 2 4GB sticks in slots A1 and A2 and then the 2 8GB sticks in slots B1 and B2. I've jut realised my explanation is a little long but I hope I have made myself clear 😛