Psychologists have been using a simple test -- the Life Orientation Test -- for years to find out. The same test has been featured in most of the research done on the relationship between optimism and pessimism and (mental) health. You can take the revised version of the test here. Be as honest as you can throughout and try not to let your response to one statement influence your response to other statements. There are no right or wrong answers.
The good news is that even if you turn out to be more of a pessimist than you think, you can learn to become more optimistic. (There are many reasons to do so. You can check them out here.) The key difference between optimists and pessimists -- which the questions on the test allude to -- is how they view success and failure. Pessimists see failure as permanent, personal and pervasive, while optimists see it as temporary, non-personal and specific. Their views on success are the opposite: Optimists see success as something long term and global, something that results from hard work. Pessimists, however, are more likely to view success as something short-term and accidental.
Imagine two students who receive the same poor grade on an exam. The first student thinks, "I'm such a failure. I always do poorly in this subject. I can't do anything right." The other student thinks, "This test was very difficult. I will do better on my next test. It was my birthday yesterday, after all."
The two students exhibit different "explanatory styles." The first sees a situation that happened because of her ("I'm bad at that subject") and that she cannot change. The second relates the poor result to something outside her (the difficulty of the specific test) and feels confident that the negative event will not repeat itself. The first student is a pessimist. The second student is an optimist.
Another example: You are on a walk and you see your friend Sarah on the other side of the street. You wave, but Sarah doesn't wave back. In fact, she turns a corner without even noticing you. If you are a pessimist, your thoughts may go back to your last conversation with Sarah; you start thinking that you may have said something wrong and that Sarah is angry with you. Soon, troubling thoughts ruin your happy walk. The negative feelings of the pessimist lead to withdrawal and inaction. You don't bounce back from a setback; you allow your negative feelings from one situation to pollute your next experience.
If you are an optimist, you would have a very different response. You would think about all the possible causes for Sarah not seeing you. She could have forgotten to put in her contact lenses that morning; she may have been lost in thoughts of her own; or she simply may have had a bad day. As an optimist, you don't lose the connection with Sarah even if she doesn't wave back. You see the cause of the setback in your life as temporary, changeable and local. You don't feel helpless. That's why optimists are happier and healthier people.
The crucial clue is that the things you tell yourself -- that endless stream of unspoken thoughts that run through your head every day -- determine your experience. The non-waving Sarah is not present. It is you with your thoughts. Changing your thoughts will change your life.