Static variables belong to the class itself and are shared among all objects of that class, while non-static variables belong to individual objects and each object has its own copy. Static variables can be accessed from any part of the program and are class specific, whereas non-static variables are specific to each object and can be accessed using instances of the class. In the provided code example, schoolName is a static variable shared by all students, while studentName is a non-static variable unique to each student object.