For given constants a and b, let
f(j,k) = (a + j) * (b + k)
We wish to maximize f(j,k) subject to three requirements:
j + k = d, for a given constant d
j >= 0
k >= 0
We can substitute out k (or j) to by replacing k with
k = d - j
This changes f to:
f(j) = (a + j) * (b + d - j)
= a*(b + d) + (b + d - a)*j -j**2
The problem is now to maximize f subject to:
0 <= j <= d
The second part of this inequality follows from k = d - j >= 0. If d = 0, j = k = 0 is the only solution that satisfies the requirement that the variables are non-negative. If d < 0 there is no feasible solution. These two cases should be checked for but I will assume d > 0.
We first set the derivative of f to zero and solve for j to determine where f's slope is zero:
f'(j) = b + d - a - 2*j = 0
so
j* = (b + d - a)/2
As the second derivative of f is
f''(j) = -2 < 0
we know f is concave, so j* is a maximum (rather than a minimum were it convex). Convex and concave functions are shown here1:

Consider the graph of the concave function. Values of j are on the horizontal axis. Since j* must be between 0 and d to be feasible (both variables have non-negative values), let the points a, c and b on the graph equal 0, j* and d, respectively.
There are three possibilities:
0 <= j* <= d, in which case that is a feasible solution (since k = d - j* >= 0).
j* < 0, in which case the largest feasible value of f is where j = 0.
j* > d, in which case the largest feasible value of f is where j = d.
Once the optimum value of j has been determined, k = d - j
Here are some examples.
Ex. 1: a = 2, b = 3, d = 5
j* = (b + d - a)/2 = (3 + 5 - 2)/2 = 3
Since 0 <= 3 <= 5, j = 3, k = 5 - 3 = 2 are the optimum values of j and k and f(3) = 25 is the optimum value.
Ex. 2: a = 6, b = 1, d = 3
j* = (b + d - a)/2 = (1 + 3 - 6)/2 = -1
Since -1 < 0, j = 0, k = 3 - 0 = 3 are the optimum values of j and k and f(0) = 24 is the optimum value.
Ex. 3: a = 2, b = 7, d = 3
j* = (b + d - a)/2 = (7 + 3 - 2)/2 = 4
Since 4 < 3, j = 3, k = 3 - 3 = 0 is the optimum value of j and f(3) = 35 is the optimum value.
If j and k must be integer-valued at the maximum value of f, we can assume a, b and d are integer-valued. (If a and b are not, a can be rounded up and b rounded down.) Let j* now be the value of j satisfying 0 <= j <= d for which is f(j) is a maximum (but j* is not necessarily an integer). Because f is concave, if j* is not integer, the optimal value of j is J*.floor if f(j*.floor) >= f(j*.ceil) and j*.ceil otherwise.
1 A function f is concave if, for all a and b, a < b, and all x, a <= x <= b, f(x) >= g(x), where g is the linear function having the property that g(a) = f(a) and g(b) = f(b).