Four major banking companies yesterday reported sharp improvements in quarterly earnings in contrast to the second quarter of 1987, when they posted large losses after setting aside special reserves against their loans to developing countries. Excluding the effects of the special reserves, the Manufacturers Hanover Corporation, the Chase Manhattan Corporation, J. P. Morgan & Company, and the Continental Illinois Corporation reported respectable, though not spectacular, earnings. ''So far, the industry is pretty much on track,'' said James J. McDermott, banking industry analyst at Keefe, Bruyette & Woods. ''They're repairing their balance sheets and improving earnings.'' Brazil Loans Still a Problem Net-interest income at all four banking companies continued to be hurt by loans to Brazil, which has still not resumed all of the interest payments on its $67 billion in foreign debt, despite the progress that has been made recently on a new loan agreement.