To calculate the molarity of a solution, we divide the number of moles of solute by the volume of the solution in liters. Given that we have 2 moles of a compound dissolved in 4 L of water, the molarity (M) of the solution can be calculated as follows:
Molarity (M) = Number of moles of solute / Volume of solution in liters
M = 2 moles / 4 L
M = 0.5 moles/liter
Therefore, the molarity of the solution is 0.5 M.