DID THE JUDGE taste every one of those cakes and pies?" the girl asked, wide-eyed at the tier upon tier of baked goods at the fair.

The boy's question was, "Who got to eat the rest?" after the slices were cut and set out with the ribbons they'd won.

The answers: Since appearance is considered, as well as flavor, some pies and cakes drop out of the running for prizes without being tasted. Most are sampled, but there are lots of judges to share the dyspepsia. The undisplayed portions (halves, at least) of the blue-ribbon winners are always auctioned off the opening night of the Montgomery County Fair, this year Monday, Aug. 21.

This is the 30th year for the fair at its Gaithersburg fairgrounds, and it's better if not bigger than ever. In fact, there are fair buffs who feel that its claim of being "Maryland's leading county fair" is overly modest, that it ranks near the top anywhere as one where a city family can find all aspects of farm life displayed in a neat, clean package with a minimum of huckstering and carnival raunch.

Part of this fair's charm stems from the nature of Montgomery County. Many of its farmers are part-time farmers, hobbyists who tend toward rare breeks of livestock and would rather grow a few of the biggest pumpkins in the world than thousands of ordinary varieties that would make them more money.

The fair has always catered to children, and its Old MacDonald's Farm is stocked with at least one of every beast and bird that has inhabited a coloring book, most of them pettable and feedable. Recent additions were white deer and miniature donkeys. This year there's to be a family of buffalo, with a sign pointing out that they really should be called bison. Kids under 12 get into the fair free the whole week, and admission is only $1 for those under 16 (adults $2). On Kids' Day, Tuesday, admission is free for all of school age and a number of rides in the midway have reduced rates. There are special games for prizes - catching a greased pig, pie eating (no hands) . . .

And at least half of the participants at the fair are kids - 4-H and FFA (Future Farmers of America) club members; their contests and demonstrations and their projects being judged contribute a major part of the constant hubbub that makes a fair a fair. Nearly all the people involved in the fair's management, including the current president, are former 4-Hers or FFA members, and they make sure that young people are involved in all planning.

Fair week is the biggest week of the year for many 4-H and FFA kids, when they find out the rewards of all the work they put into their projects. For those with meat animals as projects, the triumphs are mixed with sadness at the auction sales Friday - the smiles of pride as they stand in the ring and listen to the auctioneer rattle off the prices bid by the buyers; the tears streaming down cheeks as they realize that the animal they've raised so carefully is soon to meet the butcher.

No one ever said farming was an easy life, but you eat well. And that's reflected everywhere at the fair, especially on Wednesday with the Maryland Junior Porkecue Cookoff when 15- to 25-year-olds line up at stoves to see if their secret recipes can bring home the bacon.

Right from opening day, six food booths are operated by church groups and dish out all the healthier kinds of fast food. All the unhealthier kinds are available in profusion in the midway area. The dining hall serves full-course meals, all you can eat for $4.50, real county meals with produce straight from nearly gardens - corn on the cob, green beans, sliced tomatoes, fresh cole slaw, new potatoes; ham, roast beef and fried chicken every day with crab cakes added Friday.

The runners-up and also-ran baked goods are on sale in the home arts buildings all week, augmented by freshly baked items brought in daily. If you feel your larder is understocked after you've perused the tables of prize-winners in the food preservation department - home-canned meats, vegetables, jellies, jams, conserves, relishes in more than 120 categories - a church group has a booth selling these goods from the same or similar sources. Specialty-food firms set up booths in the exhibit halls and soft-drink firms have stands all over the fairgrounds. The dairy bar, being expanded this year, will serve a zillion flavors of ice cream. It will continue to sell pieces from the Big Cheese - a 500-pound wheel of cheddar. Last year 14 wheels were cut up - 7,000 pounds is a lot of cheese. A tip: If you like your cheddar very sharp, ask for a slice from the center of a wheel.

One of the reasons the Montgomery County Fair is so "nice" is that, unlike most fairs, the midway and the agricultural exhibits meet but don't mix. You can marvel at the cushaw pumpkins and katahdin potatoes in the produce department and go on to check the carrot marmalade blue-ribbon winner in food preservation and the wool spun from fleece in the grease in handweaving without being importuned en route by a carnival barker. The midway is all by itself at the north end of the fairgrounds, on a space about the size of three footballs fields.

It's no second-class midway. For 19 years now, the Montgomery County Fair has contracted with Dell and Travers Shows, the Barnum and Bailey of carnivals. From the top of the giant double ferris wheel you can see south to the Capitol and north to Sugar-loaf Mountain, and riders scream on the rides, there are plenty of opportunities to spend $5 trying to win a $2 stuffed animal, determined ladies play three bingo cards at once . . .

But the real action is on the south end of the fairgrounds. The action is constant, starting at 9 o'clock Monday, opening day, and even before - lots of people always visit the fairgrounds the Sunday before opening day, watching the midway being set up, the animals being unloaded.

At any given moment, right through Saturday, at least three kinds of livestock will be being judged and demonstrations given of cake-decorating and candy-making, braiding and hooking rugs, quilting, needlework, handweaving and spinning. If the tractor-pulling contests are taking a break a horse show will be going on, or dog obedience competition, plus square dances and parades of floats and the 4-H queen being crowned.

And you can just wander through the barns viewing the variety of exhibits that is the Gaithersbury fair's special charm.

In the poultry buildings at Midwestern fairs you'll see thousands upon thousands of Leghorns and Plymouth Rocks and the other major commerical breeds. At Gaithersburg, besides a sampling of those breeds, you'll find Partridge Wyandottes and Buck Brahmas, Black, Yellow and White Minaricas, Blue Cochins and Old English Games.

At the Nebraska State Fair you can see more sheep than you ever dreamed existed, almost all of them Hampshires. At Gaithersburg, there are usually more Hampshires than other breeds, but you can see Cheviots, Corriedales, Dorsets, South-downs, Suffolks and Shropshires. There are differences.

In the dairy goat barns there's a pure white breed (Saanen) and a brown breed (Toggenburg - goat raisers, a notoriously whimsical lot, may try to tell you these give the chocolate milk); a multicolored breed (Alpine); a long-eared breed (Nubian) and a breed with no ears (La Mancha - the goat raisers may try to tell you the ears fell off because of noise pollution).

In the cattle barns, the breeds are standard varieties. For a few years there were Devon cattle at Gaithersburg, all owned by Senator Wayne Morse and friends. Devons are distinctive mainly for their rambunctiousness, and were constantly getting loose and making pests of themselves; glee was barely disguised one year when one jumped the fence and was killed by a train. After Morse died the breed disappeared in these parts.

The rabbit barn always has a crowd. At any given time you can count on catching a child trying to wiggle his nose back at a Flemish Giant or a Netherland Dwarf or even a huge New Zealand. Women get a faraway look around the Giant Chinchillas, the Champagnes, the Satin and Silver Martens, imagining which they'd look best wrapped in next winter.

If about here, the kids have decided that their promised ride on the Double-Whammo-Super-Rocket-Loop-the-Loop is overdue, you can send them off to the midway, instructing them to meet you at the information kiosk in half an hour. That's where they'll be taken if they get lost, anyway. You can head back to Home Arts and buy that jar of carrot marmalads that was so intriguing.

To get to the Montgomery County Fair, take I-270 to the second Gaithersburg exit and follow signs. For schedule of a day's events, call WA6-3100. If you can't make it to that fair, here are some alternatives: