One approach we can take to actually find (and not simply check) solutions to equations like this is the method known as Variation of Parameters. (Some knowledge of linear algebra may be required for full understanding of what's going on.) Since your various terms are either constants, $y$, or some derivative of $y$, this is less difficult than it might otherwise be. Let me work through some alternate approaches, as well. (The $b\neq 0$ case is most complicated, so I'll save it for last.)
Case 2: $b=0$, $a\neq 0$.
First, put $u=y'$, so that we can rewrite our equation as $u'+au=c.$ Ideally, we'd like to deal with an equivalent equation such that both sides are just first derivatives of some functions, so that we can just integrate and go from there. To do this, we'll use what's called an integrating factor. Observe that $e^{ax}$ is a positive function, so multiplying that on both sides gives us the equivalent equation $e^{ax}u'+ae^{ax}u=ce^{ax}.$ Observe that we can rewrite this as $\left(e^{ax}u\right)'=ce^{ax}.$ [Hint: Product rule.] Integrating both sides with respect to $x$ then gives us $e^{ax}u=\frac{c}{a}e^{ax}+C_1,$ where the constant $C_1$ is there because we're taking an indefinite integral. Thus, $u=\frac{c}{a}+C_1e^{-ax},$ which means that $y'=\frac{c}{a}+C_1e^{-ax}.$ Integrating again with respect to $x$ then gives us $y=\frac{c}{a}x-\frac{C_1}{a}e^{-ax}+C_2,$ which is the general form of the solution to the equation $y''+ay'=c$ for $a\neq 0$ and $c$ some constant. The solution that your book gave you to check certainly has this form, with $C_1=C_2=0$.
Case 3: $b=a=0$.
Here, we'll start out in the same way as Case 2, by putting $u=y'$, so the equation becomes $u'=c.$ There's no need for an integrating factor to clean this up, so we immediately integrate with respect to $x$, getting $y'=u=cx+C_1,$ whence another integration with respect to $x$ gives us $y=\frac{c}{2}x^2+C_1x+C_2$ as the general form of the solution to $y''=c.$ The solution your book gave you to check once again is of the appropriate form, with $C_1=C_2=0$.
Case 1: $b\neq 0$.
We'll start by seeing if there is a polynomial solution to the differential equation. Let $p(x)=\sum_{k=0}^nd_kx^k$ (since we're dealing with second order derivatives, let's assume that $n\geq 2$ so we have enough parameters $d_k$ to play with). Then $y=p(x)$ is a solution if and only if $\begin{align}c &= \frac{d^2}{dx^2}\left(\sum_{k=0}^nd_kx^k\right)+a\frac{d}{dx}\left(\sum_{k=0}^nd_kx^k\right)+b\sum_{k=0}^nd_kx^k\\ &= \sum_{k=2}^nk(k-1)d_kx^{k-2}+\sum_{k=1}^nakd_kx^{k-1}+\sum_{k=0}^nbd_kx^k\\ &= \sum_{k=0}^{n-2}(k+2)(k+1)d_{k+2}x^k+\sum_{k=0}^{n-1}a(k+1)d_{k+1}x^k+\sum_{k=0}^nbd_kx^k\\ &= \sum_{k=0}^{n-2}\left[bd_k+a(k+1)d_{k+1}+(k+2)(k+1)d_{k+2}\right]x^k+\left(bd_{n-1}+and_n\right)x^{n-1}+bd_nx^n.\end{align}$
Since $b\neq 0$, then we can divide through by $b$ to get an equivalent chain of equations. Thus, $y=p(x)$ is a solution to the given differential equation if and only if $\frac{c}{b}=\sum_{k=0}^{n-2}\left[d_k+\frac{a(k+1)}{b}d_{k+1}+\frac{(k+2)(k+1)}{b}d_{k+2}\right]x^k+\left(d_{n-1}+\frac{an}{b}d_n\right)x^{n-1}+d_nx^n.$
Now, since polynomials in $x$ are equal if and only if their coefficients match, then we can conclude that $y=p(x)$ is a solution to the given differential equation if and only if the following system of $n+1$ linear equations is satisfied: $\begin{align}\frac{c}{b} &= d_0+\frac{a}{b}d_1+\frac{2}{b}d_2\\0 &= d_1+\frac{2a}{b}d_2+\frac{6}{b}d_3\\ &\:\vdots\\0 &= d_k+\frac{a(k+1)}{b}d_{k+1}+\frac{(k+2)(k+1)}{b}d_{k+2}\\ &\:\vdots\\0 &= d_{n-2}+\frac{a(n-1)}{b}d_{n-1}+\frac{n(n-1)}{b}d_{n}\\0 &= d_{n-1}+\frac{an}{b}d_n\\0 &= d_n\end{align}$
The last equation tells us that $d_n=0$, and back-substitution into the second-to-last equation tells us that $d_{n-1}=0$. Continuing this pattern of back-substitution up the list of equations, we find that all of $d_n,d_{n-1},...,d_1=0$, and that $d_0=\frac{c}{b}$. In other words, the only polynomial solution to the given differential equation is the constant polynomial $\frac{c}{b}$--this, of course, is the solution that your book gave you to check.
Now, note that if $f(x)$ is any solution to $y''+ay'+by=0$, then setting $y(x)=f(x)+\frac{c}{b}$ gives us $y''+ay'+by=f''(x)+af'(x)+bf(x)+b\cdot\frac{c}{b}=c.$ On the other hand, if $g(x)$ is any solution to $y''+ay'+by=c$, then setting $y(x)=g(x)-\frac{c}{b}$ gives us $y''+ay'+by=g''(x)+ag'(x)+bg(x)-b\cdot\frac{c}{b}=c-c=0.$ This gives us a correspondence between the solutions to the given differential equation and its homogeneous counterpart $y''+ay'+by=0$. In particular, if we can find the general solution to $y''+ay'+by=0$, then we'll simply add $\frac{c}{b}$ to that to get the general solution to the given differential equation.
Note that since $b\neq 0$, then there exist constants $t_1,t_2$ such that $a=t_1+t_2$ and $b=t_1t_2.$ In particular, $t_1$ and $t_2$ will be the (possibly equal) solutions to the quadratic $t^2+at+b=0$.) Then $y''+ay'+by=y''+t_1y'+t_2y'+t_1t_2y=(y'+t_2y)'+t_1(y'+t_2y),$ so letting $u=y'+t_2y$, our homogeneous equation becomes $u'+t_1u=0.$ Proceeding in much the same way as in Case 2, we'll use the integrating factor $e^{t_1x}$ to determine that $u=C_1e^{-t_1x}$ for some constant $C_1$, meaning $y'+t_2y=C_1e^{-t_1x}.$ Now, we'll do the same kind of thing, using the integrating factor $e^{t_2x},$ so $\left(e^{t_2x}y\right)'=e^{t_2x}y'+t_2e^{t_2x}y=e^{t_2x}(y'+t_2y)=e^{t_2x}\cdot C_1e^{-t_1x}=C_1e^{(t_2-t_1)x}.$ This gives us $e^{t_2x}y=\begin{cases}\frac{C_1}{t_2-t_1}e^{(t_2-t_1)x}+C_2 & t_1\neq t_2\\C_1x+C_2 & t_1=t_2\end{cases}$ for some constant $C_2$, and so $y=\begin{cases}\frac{C_1}{t_2-t_1}e^{-t_1x}+C_2e^{-t_2x} & t_1\neq t_2\\(C_1x+C_2)e^{-t_2x} & t_1=t_2.\end{cases}$ In the former case, $C_1$ is an arbitrary constant, and $t_2-t_1$ is a nonzero constant, so we may as well allow $C_1$ to "absorb" the $t_2-t_1$. Thus, our general solution to the homogeneous equation is $y=\begin{cases}C_1e^{-t_1x}+C_2e^{-t_2x} & t_1\neq t_2\\(C_1x+C_2)e^{-t_2x} & t_1=t_2,\end{cases}$ and so the general solution to the given differential equation is $y=\begin{cases}C_1e^{-t_1x}+C_2e^{-t_2x}+\frac{c}{b} & t_1\neq t_2\\(C_1x+C_2)e^{-t_2x}+\frac{c}{b} & t_1=t_2,\end{cases}$ where $t_1,t_2$ are as described above.