The question and the answer in the story
Ibn Kathir related in the tafsir a report about Yusuf the carpenter and Maryam, and he did not present it as an authentic prophetic hadith. And in the report, he is a righteous man from her relatives who serves with her in Bayt al-Maqdis (the sanctuary in Jerusalem).
The story says that he saw the signs of pregnancy, and he disapproved of that, then it mentions her innocence and her religion and her worship. So he remained thinking, then said: ‘O Maryam, I am going to ask you about a matter, so do not be hasty with me.’ She said: ‘What is it?’ He said: ‘Can there be a tree without a seed? Can there be a crop without seed? Can there be a child without a father?’
So she said, in the story: ‘Yes.’ And she understood what he alluded to. Then she said: ‘As for your saying: Can there be a tree without a seed and a crop without seed? For Allah created the tree and the crop the first time He created them without seed. And can there be a creation without a father? For Allah created Adam without a father or a mother.’ So he believed her and accepted her state. And the description of her being betrothed to him is not established by this report.
