Suppose if I want to take a mean of all 30 students in a class, then does the class represent a population or sample?
It can be both, depending on your approach, your questions and your goal. Sometimes your goal may be to describe what happens in this specific class for purposes concerning this particular class. Sometimes the same class may stand in as an example from which you want to extrapolate to classes or students in general.
Whenever you are concerned with only this specific class, the class is the population. Whenever you want to generalize from your class to other classes (whether they actually exist or just be hypothetical) then this class is just a sample from the other possible classes.
Obviously you can compute the mean in both cases. However, they are not the same. The mean of the population is a fact you can compute. The mean of the sample (the second case) is an estimator that comes with a sampling error, stems from a distribution and has a standard error. Dealing with estimators instead of precise measurements, dealing with sampling error etc. is the heart of the science called Statistics.
So while computing a mean of a class that you consider a population is possible, it is mostly boring. You neither need a textbook nor a forum for that. The mean of a class that you consider to be a sample is where all those questions arise, how much you can tell about the population from your limited sample. This is where Statistics shines. This is why people use CrossValidated.