2 Chronicles 23:3
And all the congregation made a covenant with the king in the house of God. And he said unto them, Behold, the king’s son shall reign, as the LORD hath said of the sons of David. And all the congregation made a covenant with the king in the house of God. And he said unto them, Behold, the king’s son shall reign, as the LORD hath said of the sons of David.
The verse belongs to the account of the reigns of Athaliah and Joash and the service of Jehoiada the priest, within the history of Judah's kings. In that history Athaliah reigned seven years and Joash reigned forty years. The verse records Joash being established and proclaimed as king in the house of God after Athaliah's rule ended. Athaliah had usurped the throne and tried to destroy her son's children, and when her reign became corrupt the people revolted and she was slain.
Joash was the surviving son of Ahaziah, hidden in the temple as an infant child and then brought out and made king at seven years old. His reign preserved the royal line of David as promised, and he did right while Jehoiada the high priest counseled him. The surrounding history teaches that doing duty brought blessing, while departing from God brought strife, captivity, and loss.