How were the planets in the solar system formed?

A: The dust particles were attracted by gravity from distant galaxies.
B: The gas particles released by the sun were pulled away and became solid.
C: The solid materials were forced out of the suns's disc and cooled down.
D: The remaining materials from the suns's formation clumped together due to gravity

D: The remaining materials from the sun's formation clumped together due to gravity