When I took Java in high school, I always finished projects faster than everybody else. Sometimes when I finished, I kept going just to entertain myself. At least once, I did something not knowing we were about to do it anyway, which put me really far ahead. It did get pretty boring, but we were allowed to do whatever we wanted when we finished, so I played a lot of games.
Later when I took German in college, I found it to be much easier than the others in my class did. Since I always did pretty well with in-class discussion and tests, the prof. realized it wasn't very challenging for me and kind of boring, so she let me get away with not doing a lot of homework. I always came up with spontaneous answers when we went over things in class anyway.
And in Flash I was several chapters ahead until I got so bored of it I just couldn't be bothered to read the book anymore. That class was stupid and didn't teach anything, anyway. We taught ourselves from the book while the prof. chattered and interrupted all the time. It was annoying, and I just messed around online most of the time. She didn't care, especially since she knew how easy it was for me.
Unfortunately it isn't always that easy (see that I only have 3 examples after 5 years of college). But if I am ahead of everyone else, I usually just work ahead or find something else to do.
_________________
"If knowledge can create problems, it is not through ignorance that we can solve them." - Isaac Asimov