This is analogous to the dynamic programming solution to 0/1 knapsack problem.
Consider the Capacity of the knapsack W analogous to J(the total sum here).
The Solution exploits the optimal substructure of the problem.
At each stage we can have 2 options
Case (1)Either we take an item(in this question either we consider the element Ai) along with the total solution to previous sub-problem(total solution here means the total sum obtained till previous sub-problem)
in which case we choose A[i-1][j-ai]
A[i-1] indicates we are considering solution to previous subproblem and
A[j-ai] means we have considered element ai and now remaining sum is J-ai which has to be further considered.
Case (2) Or we do not consider the item(in this case the element ai) in which case we only consider the solution to previous subproblem.
which is A[i-1][J]
Since the whole solution to this subset-sum problem is Logical OR(+) of cases 1 and 2
we eliminate options C and D because both are considering the Logical AND of the two part of solution.
Now Since here in the given question we are given a boolean array X[n][W+1]
So An entry X[i][j] is true only if sum j is possible with array elements from 0 to i.
So for Each element of array, ai, we consider two possibilites
(1) EIther we can ignore it and still get our possible sum
Which is X[i-1][j]
(2) We could include element ai and then get our required sum.
Which is X[i-1][j-ai]
And finally, to get X[i][j], we take logical or of the above two cases.
Hence answer is option B.
By using the analogy of the problem and solution between subset-sum problem and 0-1 knapsack problem, the above video clearly explains the how the solution to the problem is structured .