How do I know when a form represents an integral cohomology class?
Solution 1:
With regard to your last question, you're on a good path for examples. Following @Qiaochu's first example, we have the closed $2$-form $\omega$ that generates $H^2(\mathbb R^3-\{0\}) \cong H^2(S^2)$:
$$\omega = \frac{x\,dy\wedge dz + y\, dz\wedge dx + z\, dx\wedge dy}{(x^2+y^2+z^2)^{3/2}}\,.$$
This should look familiar if you interpret it as the flux $2$-form of the gravitational or electric force with a particle at the origin and think of Gauss's Law. As it stands, this $2$-form is not integral, as the integral over any closed surface containing the origin, say, the unit sphere, is $4\pi$. But we can normalize and get an integral class: $\frac1{4\pi}\omega$ is now the generator of $H^2(S^2,\mathbb Z)$.
You can make this work analogously by normalizing "the" volume form for any compact, orientable $n$-manifold.
However, one of @Qiaochu's statements is wrong. If we take $M=S^2(1)\times S^2(\pi)$ (where by these numbers I mean radii), then the element of $H^2(M)$ that corresponds to the sum of the respective area forms (officially, pulled back by the canonical projections) is not an integral class, and no scalar multiple of it is (because $H^2(M)\cong \mathbb R\oplus\mathbb R$).
Solution 2:
On $M = \mathbb{R}^2 \setminus \{ (0, 0) \}$ consider the differential form
$$\omega = \frac{1}{2\pi} \frac{x \, dy - y \, dx}{x^2 + y^2}.$$
This is a closed $1$-form. Its integral over a path in $M$ is its winding number; in particular, it is always an integer.
For nontrivial examples of integral $2$-forms you just need to find examples of nontrivial complex line bundles. More precisely, any such form is the curvature form of a connection on a complex line bundle $L$, and the corresponding integral cohomology class is the first Chern class $c_1(L)$ of $L$. This is a special case of Chern-Weil theory. This example comes up in physics when discussing Dirac's quantization argument; see, for example, this paper by Bott.