Is wearing a cap permissible for boys, or girls?
All Perfect Praise is due to Allah, The Lord of The Worlds.
In principle, anything is permissible sol long as there is no Sharia evidence prohibiting it, thus wearing the cap by boys is permissible as long as it isn`t done in imitation of the disbelievers. Moreover, a Muslim woman should avoid all that which attracts the attention of men because whatever leads to the forbidden is forbidden. And Allah Knows Best.
What is the ruling on the chatting between a young man and his girlfriend?
Private chatting between the two sexes entails religious violations, and leads to prohibited attachment.
Is it permissible for one to masturbate in order not to commit fornication?
This is called committing the milder of the two evils such as eating a carcass in fear of death, and this happens when committing fornication is very likely to occur.
What is the ruling on a person in a state of major impurity (junub) or a menstruating woman (ha'id) reciting the Quran from memory?
It is not permissible for a menstruating woman, a postpartum woman, or a person in a state of major impurity to recite anything from the Quran, whether from memory, from the Quran, from a phone, or a computer. It is also not permissible for them to touch the Quran, based on what was reported from Ali bin Abi Talib that the Prophet (peace be upon him) was not prevented from anything regarding the Quran except major impurity (janabah). (Reported by al-Tirmidhi who said it is a hasan sahih hadith). Menstruation and postpartum bleeding are analogous to major impurity (janabah) as they are all major impurities (hadath akbar).
For those mentioned, it is permissible to mention Allah and supplicate even with verses from the Quran, provided they do not intend them as recitation of the Quran, but intend them as remembrance (dhikr) or supplication (du'a). And Allah the Almighty knows best.