Please help ,I am new to segment tree topic… I stuck on this code…

int query_tree(int node, int a, int b, int i, int j) {

```
if(a > b || a > j || b < i) return -inf; // Out of range
if(a >= i && b <= j) // Current segment is totally within range [i, j]
return tree[node];
int q1 = query_tree(node*2, a, (a+b)/2, i, j); // Query left child
int q2 = query_tree(1+node*2, 1+(a+b)/2, b, i, j); // Query right child
int res = max(q1, q2); // Return final result
return res;
```

}

In the above code ,how this line is working:

if(a >= i && b <= j) // Current segment is totally within range [i, j]

return tree[node];

If [a,b] is within [i,j] ,then how can it ensure that maximum value will occur within [a,b] ? what about interval [i,a] ans [b,j] ?