Since, , the line lies in between the points A and B.
Consider the line which goes through A and B. Its equation is,
Now the point P lies on the line .
Since k>0, it is clear that y would be a maximum when the point P lies on AB (Please refer to your diagram).
Hope this will help you.