Yes, if you sell on the Ex-Div date or later, you get the dividend. If you sell before the Ex-Div date, you will not. Reason: The share price is reduced by the amount of the dividend on the Ex-Div date. If you try to beat the price reduction by selling before Ex-Div, then you forfeit the dividend. If you suffer the price reduction, you get the dividend.
Yes, because the stock went ex-dividend to pay the holders as of the morning of ex-date. You had to own it the night before ex-date to collect it. Once it goes ex-dividend, you can sell and still get the dividend.