What you typically do in these cases are:
You differentiate the function and find max and minima.
But here you also need to test the endpoints of the interval.
You know how to perform a second derivative test to test for minima or maxima?
Some functions may not have a global maxima, if say a function is defined on , that is, the endpoints are not included, and the function in strictly growing, there might now exist a global maxima. Because whenever you pick a number close to 2, say 1.999 , you can always choose insted 1.999999 , and the function attains a higher value.
So keep a distinction between closed and open intervals.