How print a selected item in drop-down

thank you guys
I read everything and decided to take a test
I got it as follows:

import org.openqa.selenium.By
import org.openqa.selenium.support.ui.Select
import com.kms.katalon.core.webui.driver.DriverFactory

Select select = new Select(DriverFactory.getWebDriver().findElement(By.xpath("//select[@id=‘myDropdown’]")))
String MyLabel = select.getFirstSelectedOption().getText()

Source: How to get text of the selected option in the dropdown