The basic structure used in describing what you can and cannot do in Japanese is "koto ga dekimasu." This phrase is a sentence in and of itself, and has two parts, "koto ga" and "dekimasu." The first part, "koto ga," consists of the word "koto," meaning thing, and the particle "ga," indicating that "koto" is taking the action in the sentence. The second part, "dekimasu," is our verb. Literally, it means "is possible" or "is able to be done." Like most Japanese verbs, it can be negated by changing the ending, making "dekimasen" the negative form. We now have the basic structure for our sentences. We will use "koto ga dekimasu" for sentences involving "can," and "koto ga dekimasen" for sentences involving "cannot."
To ask someone if they can or cannot do something, we start with a verb. For this example, we will use "nihongo wo hanasu" — to speak Japanese. For this sentence structure, we will always leave the verb in its dictionary form (hanasu), no matter the conjugation. This makes this particular grammar point quite easy, as all conjugation is done with "dekimasu." To ask someone if they can do something, in our example "speak Japanese", we simply add the verb before "koto ga dekimasu," as shown below:
Nihongo wo hanasu koto ga dekimasu ka?
The particle "ka" is added at the end to indicate that it is a question. Literally translated, this sentence comes out as "Speaking Japanese, can it be done [by you]?" — as with many Japanese questions, the "you" is simply understood and not spoken. As strange as this pattern may seem, it is a very common one in Japanese. A more natural translation gives us "Can you speak Japanese?" Here is another example:
Kono kanji wo yomu koto ga dekimasu ka?
The first part, "kono kanji wo yomu," is translated as "read this kanji", so the whole sentence would translately naturally as "Can you read this kanji?"
Yes I can/No I cannot
To answer the question of "Can you…?" we use a very simple response. If you want to say that yes, you can do the action in question, such as speak Japanese, you respond with "Hai, dekimasu." This literally translates as "Yes, it can be done" but more naturally we would say "Yes, I can." In English, it would sound awkward to hear "Can you speak Japanese? Yes, I can speak Japanese." — we simply say "Yes, I can." Japanese is the same way, dropping the actual action from the response. In fact, if you want to be brief, you can even just say "Dekimasu" by itself.
But what if you cannot perform the action in question? All you have to do is answer with "Iie, dekimasen." Both the positive and negative responses are very polite, and can be used in any situation. "Dekimasu" is a very useful phrase in Japanese, and one you will hear on a regular basis in Japan. Learning it will get you one step closer to saying "Nihongo wo hanasu koto ga dekimasu!" (I can speak Japanese!)