Concept:
To check whether a function is a solution of a differential equation, substitute the function and its derivatives into the equation.
The given differential equation is
\[
\frac{d^2y}{dx^2}+y=1
\]
Step 1: Find the general nature of the solution.
The complementary equation is
\[
\frac{d^2y}{dx^2}+y=0
\]
Its auxiliary equation is
\[
m^2+1=0
\]
\[
m=\pm i
\]
So the complementary function is
\[
c_1\cos x+c_2\sin x
\]
Step 2: Find a particular solution.
Since the right side is \(1\), take a constant particular solution:
\[
y_p=1
\]
Then,
\[
y_p''=0
\]
and
\[
y_p''+y_p=0+1=1
\]
So \(y_p=1\) is valid.
Step 3: Write the general solution.
\[
y=1+c_1\cos x+c_2\sin x
\]
Therefore, any solution must have constant term \(1\).
Step 4: Check the options.
\[
y=1
\]
is a solution.
\[
y=1+\cos x
\]
is a solution.
\[
y=1+\sin x
\]
is also a solution.
But
\[
y=2+\sin x+\cos x
\]
has constant term \(2\), not \(1\).
Step 5: Direct verification of option (D).
If
\[
y=2+\sin x+\cos x
\]
then
\[
y''=-\sin x-\cos x
\]
So,
\[
y''+y=(-\sin x-\cos x)+(2+\sin x+\cos x)
\]
\[
y''+y=2
\]
But the equation requires
\[
y''+y=1
\]
Hence option (D) is not a solution.
Step 6: Final answer.
\[
\boxed{y=2+\sin x+\cos x}
\]