We consider the finite difference method for the approximation
$\left\{\begin{matrix} -u''(x)+q(x)u(x)=f(x)\\ u'(a)=u'(b)=0 \end{matrix}\right.$
and let $K$ be the $(N+2) \times (N+2)$ matrix of the method. Let $v \in \mathbb{R}^{N+2}, v=\begin{pmatrix} v_0\\ v_1\\ \dots\\ \dots\\ \dots\\ v_{N+1} \end{pmatrix}$
If $(Ku)_i \leq 0 \forall i=0,1, \dots, N-1$ then $\max_{1 \leq i \leq N} \{ v_i \} \leq \max \{ v_0, v_{N+1},0\} (\star)$
Proof:
We suppose that $(\star)$ does not hold.
Then $\exists n \in \{ 1,2, \dots, N\}$ such that $v_n= \max_{1 \leq i \leq N} v_i >0$, $v_n>v_0$ and $v_n > v_{N+1}$.
Now $(Ku)_n=u_{n-1}+(2+h^2 q(x_n))v_n-v_{n+1} \leq 0 \Rightarrow (2+h^2 q(x_n)) v_n \leq v_{n-1}+v_{n+1}$
but $v_n \geq v_{n-1}$ and $v_n \geq v_{n+1} \Rightarrow 2 v_n \geq v_{n-1}+v_{n+1}$
Thus, $(2+h^2 q(x_n))v_n \leq v_{n-1}+v_{n+1} \leq 2 v_n$
This can only hold if $q(x_n)=0$ and $v_n=v_{n-1}=v_{n+1} \Rightarrow \dots \Rightarrow v_i=v_n \forall i$, contradiction.
Could you explain me why it holds that $(Ku)_n=u_{n-1}+(2+h^2 q(x_n))v_n-v_{n+1}$ ?
You first have to verify that the property holds for the analytical solution. This property does not hold every time, for example $$u=\sin^3 x, \quad x\in[a,b]=[0,\pi]$$ satisfies the equation and the boundary condition for every $q(x)$ with $$f(x)=q(x)+3) \sin^3x-6 \sin x \cos ^2x$$ Note that $u(0)=0$ , $u(\pi)=0$ but $u(\pi/2)=1$
Consequently, the property cannot hold for discrete solution.
Finally, the maximum is not necessarily holds at the end points of the interval.