Solutions

While moving from (0, 0) to (a, 0) along positive x-axis,
y = 0
i.e., force is in negative y-direction while the displacement is in positive x-direction. Therefore, W1 = 0 (Force ⊥L displacement).
Then it moves from (a, 0) to (a, a) along a line parallel to y-axis (x = +a). During this 
The first component of force, −ky will not contribute any work because this component is along negative x-direction
while displacement is in positive y-direction (a,0) to (a, a).
The second component of force i.e., −
will perform negative work

Note: In the given force, work done is path independent. It depends only on initial and final positions. Therefore, first method is brief and correct.