In general, each class is in a separate file. The class has methods that can be called from within the class or from outside the class. If one of the methods is called main() that will be called if the class is run as an application. Otherwise, when an object is created from a class, other than the constructor, nothing is run automatically.
Applets follow the same rules as classes without the "main" method: they just hang around waiting for something to call their methods. The difference is that there's not another java class interacting with them, but a web browser. As mentioned, the web browser calls init(), start(), stop(), destroy(), paint(), update(). The applet has no control over when those methods are called. paint() could be called repeatedly for a few minutes as the user scrolls or otherwise interacts with the web page, then not called again ever unless the applet kicks off a thread to call it periodically with the repaint() method (which simply requests the browser to call the applet's own paint() method).
You can have a main() method in your applet and run it as an application, as long as it's coded correctly. There's more work setting up the context, but some of the things may not apply to one mode of operation or the other, but it can be done.