Attending every lecture is the most efficient way to learn the material and get good grades regardless of the class. I realize this is not really aligned with the other answers here, so let me explain in some more detail.
There are 3 different ways to make class time extremely efficient:
1) Paying careful attention in class: There are some classes where being hyper-attentive is the best way to learn the relevant material quickly. This includes classes where the material is difficult to understand, such as a solid state physics class. It also include classes where conversation with peers/professor is the main mechanism of learning, such as management classes that are case based.
2) Paying passive attention in class: Sometimes, there is certain classes where you gain the most by listening to 30% of the class material, but you can use the rest of the time to study while sitting in the class. My typical example of a class like this is accounting. You don’t need to listen to all of it. However, you do need to know that 30% that is tricky. So the way to use class time is to study, or do homework. This way you are reading, listening and revising all in class time.
3) Paying almost no attention in class: Sometimes, you are going to class to fill in minor gaps or specific topics. However, here again, I think going to class is the best way to be efficient. Use the time to study on your own, and listen to the 1 or 2 pieces where there is a gap. Even better, make note of the few topics that are most important to the class, to make test studying even more efficient. If you are really good, you will have started the homework beforehand, and via lecture fill the gaps to solve in while in class.