Help finding the LCD w/variables & exponents in the equation

I'm learning how to add and subtract fractions that contain exponents and variables but my book does a horrible job of explaining how you obtain the LCD to solve a given equation. For example, the book lists the following 2 problems to show how it's done but I can't decipher what formula / rule they're using to get the LCD as the book is not very straight forward in explaining the process.

4/x^2 + 7/x

The book gives an LCD of x^2

and

3/xy - 4/y^2

The book gives an LCD of xy^2

If somebody can walk me through these problems I would appreciate the help very much.