The petition under section 24 may be heard on the merits when a child is taken into custody and brought before the court or may be continued to a time fixed for hearing. Pending the hearing on the merits, the court may allow the child to be placed in the care of some suitable person or licensed agency providing foster care for children or may commit the child to the custody of the department. If the court commits a child to the custody of the department, the court shall consider the provisions of section 29C and shall make the written certification and determinations required by said section 29C.
Mass. Gen. Laws ch. 119, § 25