The sample of 10 items can have at most 2 defective items. This allows the sample of items that is chosen to have either 2 defective items, 1 defective item or no defective item.
A number of samples of 10 items with n defective items is obtained by choosing 10-n items from the 40 items that are not defective and choosing n defective items from the 10 items that are defective. This can be done in 40C(10-n)*10Cn ways.
The number of samples with 2 defective items is equal to 40C8*10C2
The number of samples with 1 defective item is equal to 40C9*10C1
And the number of samples with no defective item is equal to 40C10.
The total number of possible samples is 40C8*10C2 + 40C9*10C1 + 40C10.