Your ODE can be rewritten as $y''-2y=0$. So you can assoiciate it to the polynomial $p(x)=x^2-2$, which has the roots $\pm \sqrt{2}$. Therefore the general sulution is given by $y(x)=ae^{-\sqrt{2}}+be^{\sqrt{2}}$.
Let me explain why this i true (the following can be done rigorously, but I'll show you the idea behind it, because I think it's easier to remember ideas than general techniques).
Let's have a look at a more general situation. Consider
$$y^{(n)}+a_{n-1}y^{(n-1)}+...+a_1y'+a_0y=0.$$
We now want to guess solutions. For this we assume $y$ can be written as $y(x)=e^{\lambda x}$. Observe that in this form $y^{(k)}(x)=\lambda^k e^{\lambda x}$. Plugging this into our equation and dividing by $e^{\lambda x}$ yields $$p(\lambda):= \lambda^{n}+a_{n-1}\lambda^{n-1}+...+a_1\lambda+a_0=0.$$ So you can associate your ODE to a polynomial. If $\lambda_1,...,\lambda_n$ are the (complex) roots of this polynomial, then $y_k(x)=e^{\lambda_k x}$ is a solution for your ODE. Because this type of ODE is linear, the general solution is given by
$$y(x)=b_1y_1(x)+...+b_ny_n(x).$$
If one of the rootes is complex (and therefore another one), just take the real and imaginary part of the corresponding $y_k$.