1) what is the difference between D and JK flip flops? both of them are used to store one bit, so how can I choose which one to use for a certain application?
The D Flip-Flop captures the data on the D-input at the rising edge of the clock and propagates it to the Q an Q-Bar outputs.
The JK is more flexible. At the clock edge it can SET, CLEAR, HOLD, or TOGGLE. Since it hat 2 inputs labeled J and K it can do four things instead of two for the D-Flip-Flop (SET and CLEAR)
Doing a long synchronous counter is much easier with a JK
Doing state machines can reduce the need for external logic
Doing registers in an ALU is easier with a JK