Powers of courts to pass a sentence of detention in a Borstal Institution in the case of a convict under twenty one years of age in lieu of transportation or rigorous imprisonment (1) When any male person less than twenty one years of age is convicted of an offence by a court of sessions, a Magistrate specially empowered under section 30 of the Code of Criminal Procedure, 1898, or a Judicial Magistrate of the first class, or is ordered to give security for good behaviour and fails to give such security, and when by reason of this criminal habits or tendencies or associations with persons of bad character it is expedient in the opinion of the Judge or Magistrate, that he should be detained, such Judge or Magistrate may, in lieu of passing a sentence of transportation or rigorous imprisonment, pass an order of detention for a term which shall not be less than two years and shall not exceed seven years when the order is passed by a Court of sessions or a Magistrate specially empowered under section 30 of the Code of Criminal Procedure, 1898, and shall not be less than two years nor exceed three years, when the order is passed by a judicial magistrate of the first class not so empowered.