The bitter taste is caused by the presence of terpenoid compounds called cucurbitacins, named for the cucumber and squash family of plants called cucurbits. Cucumbers produce cucurbitacins as a defense against insects, fungus and herbivores.
Dear Rajiv .. as mentioned earlier, the bitterness in cucumbers is caused by so-called cucurbitacins. You can find the answer to your question e.g. in this useful link entitled "Master Gardener: Fighting bitterness in cucumbers":
There are also some research articles on cucurbitacins available directly on RG, e.g.:
Article Cucurbitacins and its Anticancer property: A Review
Article Cucurbitacins: Bioactivities and synergistic effect with sma...
Article Cucurbitacins: Elucidation of their interactions with the cytoskeleton
Article Cucurbitacins a Vibrant Triterpenoid: A Review on its Antica...
All these articles are available as public full texts. As you can see from these papers, the cucurbitacins do not only cause the bitterness, but they also have promising anti-cancer activities.
BitterBitterness in cucurbits is due to the presence of cucurbitacin. It may be due to water scarcity during the early fruit development and it is also due to the genetic cause in some wild species of the cucumber and wild varieties of the Luffa species. The bitterness of Bitter gourd is different which is due to Momordicin, it is good for health but other than bitter gourd bitterness of cucurbits is due to cucurbitacin which is not good for human health and suggested that not to be consumed. The chemical substance is cucurbitacin and it is chemically classified as triterpenes. Triterpene is a hydrocarbon formed from unsaturated variant cucurbit-5-ene. The bitterness of the plant acts as a defence mechanism against herbivores. The derivatives are found in many plant families that include Brassicaceae, Begoniaceae, Rosaceae, Rubiaceae, and in some of the mushrooms. Cucurbitacin has a number of variants that range from cucurbitacin A to cucurbitacin T. The bitterness in cucurbits plants is influenced by some other factors such as environmental stress like temperature is too high or too low induce the bitterness in these plant species, and lack of water in such plant bodies also induced the bitterness. Cucurbitacin is present in different plants and their parts such as cucumber, zucchini, melon, and pumpkin. Cucurbitacin compounds show some other biological properties like toxicity and in some pharmacological industries for cancer, diabetes, inflammation, and cardiovascular disease. The toxicity is induced due to the high intake of cucurbitacin which causes toxic squash syndrome.
The concentration of cucurbitacin toxin is also influenced by cross-pollination with wild species of Cucurbitaceous species. Bi genes are responsible for the bitterness of the entire plant. Bitterness in fruit requires two genes such as the Bi and Bt genes.