A child needs to be able to comprehend things and be found fit to testify in court which is usually by age 3 or 4 at the latest.
If the child is under 3 then they likely will not want to even try to question the child because at that age they can't be trusted with their answers in court.
Some courts may not allow a 4 year old to testify in court while some may allow them too as it all depends on the court and the child.
The judge will usually take the child into their chambers and ask them a few questions and see if they have the ability to give a good answer and testimony in court and if not then they won't allow them to testify in court.
Children can make up things so it would not be too good of an idea to rely fully on their answers in court although they may need to testify against someone who has touched them wrongly or abused them.