Steam Locomotives
In general, steam locomotives were classified using the Whyte system. This system counts the number of wheels in each of the three or four sections of the engine. For example, a steam locomotive with two leading wheels, 8 driving wheels, and 2 trailing wheels was flagged as a "2-8-2". Note that each wheel on the axle was counted.
However, the Pennsylvania Railroad, being the "Standard Railroad of the World", classified their engines differently. Each steam and electric engine was classified according to its wheel arrangement in groups represented by a capital letter of the alphabet. For example, a "2-10-4" steam engine was classified by the Pennsy as a "J". This letter was usually followed by a dash and a number indicating the design change. For example, a "J-1" was the first design of the "2-10-4" group.
Diesel Locomotives
For diesel engines a two-letter format was used along with a dash and a number. The first letter indicated the builder and the second letter the primary purpose of the engine. For road-going diesels, the number after the letters represented the number of engines in the train (or lash-up). For example, an "EF-4" was a collection of four diesel freight engines built by EMD.
For diesel switcher engines, the same two-letter method was used, but the number after the dash represents the hundreds of horsepower the engine produced. For example, an "AS-10" was an Alco-built switcher that produced 1000hp.
These are the first letter possibilities:
These are the second letter possibilities:
Some information came from the Wikipedia web site, and some from books I own.