ANSWER: Yes, both Mary and Joseph were descendants of David. The genealogical record in the first chapter of Matthew is Joseph’s family line. However, there is another family tree in the 3rd chapter of Luke. That record lists Joseph as the father, but all of his forefathers are different from those listed in Matthew until you get to David. The reason is, the genealogy in Luke is Mary’s ancestry. But because only the male family heads were taken into account Mary is not listed, even though it is her family tree.
Take note of the wording at Luke 3:23, which states: “When Jesus began his work, he was about 30 years old, being the son, as the opinion was, of Joseph, son of Heli…”
Doctor Luke, who assured his friend Theophilus in the opening words of his letter to him, now known as the gospel according to Luke, that he had traced all things with accuracy, apparently searched out the public records and published Mary’s ancestral lineage exactly as he found it. Obviously, though, the birth record did not state that Joseph was merely the stepfather or that Jesus was born miraculously. That is why Luke was compelled to say that it was only the popular opinion that Joseph was the father of Jesus.
It certainly seems as if Jehovah did not want there to be any question about the legitimacy of Jesus being a son of David, as both Joseph and Mary were his descendants; Mary through David’s son, Nathan, and Joseph through Solomon and the royal line.
As regard Jesus’ genetics, it is true that Joseph was not the biological father of Jesus. However, Mary was the biological mother. As the Father of Jesus Jehovah did not merely convert his heavenly son into an embryo and implant it in Mary, as might be done nowadays in embryonic implantation. The reason we know that could not have been the method God used is because it was necessary for Jesus to be related to the human race, not just a stand-alone human produced from alien stock. If Jesus was to die a substitutionary death for Adam’s offspring he had to be related to them. This was a principle embodied in the Mosaic Law that allowed the next of kin the rights of repurchase, which allowed a close relative to buy his kin out of slavery. So, in order for Jesus to fulfill that aspect of the law he had to actually be a next of kin to Adam’s sin-enslaved children. The trick is, though, Jesus had to be sin free. (Here is someinformation on repurchasing.)
The only way it would work is if Jehovah miraculously fertilized one of Mary’s eggs with a sperm cell that had been imprinted with the life-force of his heavenly son. It would also require that God prevent the sin-damaged genes of Mary from effecting the embryo. That was evidently accomplished by means of what the angel explained to Mary, when he said: “Holy spirit will come upon you, and power of the Most High will overshadow you. And for that reason the one who is born will be called holy, God’s Son.” In this way Jesus would be grafted into the human race, so-too-speak, via Mary’s genetic material.
Not only was Jesus related to mankind and hence, the Son of man, but he was also a descendent of David, which entitled him to the throne of Israel.
Here is some more information in the Insight volume under the topic ofgenealogy.