Sometimes, but not always, managers are looking for people that can do the work they are given, but are also able to independently solve problems they encounter without too much intervention, supervision and "bothersome" questions.
There are two mind games that I use to overcome a boss who micro-manages one moment, then becomes unavailable for long periods of time.
First game: Imagine being the boss. After all, the boss always gets to stay in the office, while the workers run about. Imagine your manager as another resource for you (e.g. the person who will acquire the tools you need, grant you access to company resources, sign your timesheet). You can now skew that view to your advantage. If you know where everything is, you become the resource for answers, and your manager becomes the resource for action.
Now that you are, at least in your mind, the boss, you are the one that has to produce the answers. You are the one that will gain the reward for correct answers, and suffer the consequences of incorrect ones. Look towards taking control of your own destiny within the framework of your existing job.
Second game: Ask yourself whether you should ask a question or find the answer on your own.
Imagine if had to pay $100 for every question you ask your manager, like that of certain software companies' technical support. You may find yourself answering the original question without intervention, from an outside resource, or as a product of some logical line of thought, trial and error, or perhaps even a good guess.
Many technical folks are left to their own devices when they first start in the field, and again when they become accomplished. Try to solve problems, even if it means just straightening up your workspace, organizing your work, or documenting and optimizing your workflow.
If you find yourself with little to do, it will appear as though you are efficient, organized and capable. Technical people often find themselves inundated with technical work, while these important sanity preserving tasks are pushed aside. Use the time for self study and train yourself on some work-related aspect of the job, even if it as simple as creating your own technical web pages using the company's design elements. This will make you appear that you are attempting to contribute to the entire organization.
Most importantly, have a list of written questions prepared so that when your manager does finally return, you won't appear to have wasted time or impeded progress on projects.