Students started lining up early the other morning in an anteroom outside a small office at Stanford University here, each waiting for his or her allotted 10 minutes with 1980 independent presidential candidate John B. Anderson.

Some were enrolled in one of two political science courses Anderson is teaching at Stanford this quarter. Others appeared to have been drawn more by his celebrity status. And still others showing up for Anderson's "office hours' merely wanted to tell him that if he runs for president again, they'd like to work in his campaign.

Anderson suffered through the two hours of appointments gracefully, answering sometimes inane questions, laughing and joking and even managing a smile at an occasional pointed reference to his unsuccessful campaign.

"I voted for you last time, but I probably wouldn't do it again," one student told him in a burst of candor. Anderson good-naturedly replied, "That's pretty hard to take this early in the morning."

It's a long way from the excitement of a presidential campaign to the comparatively subdued atmosphere of a college campus, but even out-of-work politicians have to earn a living. So the 59-year-old Anderson signed on this spring as a guest professor here, for $10,000, and commutes weekly from his home in Illinois.

As in politics, however, the going on campus is not always easy. Anderson, who spent 20 years in Congress as a Republican representative from Illinois before his independent try at the presidency, has been snubbed by some political science professors who have questioned his credentials to teach.

And enrollment in his "Congress in Transition" class, which drew 400 students, has dropped to about 200 after the initial burst of enthusiasm.

"When I heard they were bringing him here as a guest professor," Hubert R. Marshall, a political science professor, said, "it crossed my mind that it might not be worth it. Students are probably finding that he's not the most qualified professor to speak on Congress."

Some students said they found his lectures boring and disjointed. One said that while Anderson was a forceful speaker, his lectures were more "like a political rally" and "he doesn't say anything."

But a more likley explanation is that many students signed up for his course out of curiosity. Instead, Anderson made it clear he was there to teach, not discuss his campaign. This would be no snap course, he said, and then he hit them with a heavy reading list, a requirement for a 10- to 11-page paper and prospects of a tough final exam.

"A lot of people always drop out of classes. You had to have something more than the glamor of being in a John Anderson class to sustain you through all that reading," said sophomore Dave Fredericks, adding that Anderson's lecturing has "gotton better."

Anderson, however, takes the criticism in stride, often exhibiting a relaxed side of his personality, and a sense of humor.

"The House Foreign Affairs Committee decided several years ago that they wanted to broaden the scope of their responsibilities and so they had themselves renamed Internationl Relations Committee. They didn't see why it was only the Senate that could have foreign relations and the House had to have merely affairs," he told his early afternoon class last week, to gales of laughter.

In addition to his large lecture class on Congress, Anderson also teaches a seminar on the political process, called "Political Parties in Transition." It was restricted to 14 students, and it is here that the focus often centers on his efforts at running for president outside the traditional two-party system.

"I try to discourage it," he said, "but it's very hard to stay away from that."