Luke 2:46. They found him in the temple, sitting in the midst of the doctors, both hearing them, and asking them questions.
There were several places within the Temple area where doctors of the law met their disciples. One of these places was in the cloisters described in the note on Matthew 24:1 (#704). Another was in the synagogue which was in the Temple enclosure. After service the doctors admitted any who wished to converse with them on matters pertaining to the law. There were also other places resorted to for a similar purpose; and Lightfoot declares that it was not impossible for Jesus to have been in the great Sanhedrim itself.
There is no reason to suppose that in the conversation which Jesus held with these learned men there was anything like controversy. He simply followed the custom of the time, which allowed anyone who chose to question the doctors on any points on which they desired information.