All of us run into and have to deal with people who are a tad bit overly confident. Some might call it arrogance and some might call it prideful, egocentric and self-centered. Regardless of what we might classify it as, it's important to know how to deal with these type of people without allowing them to ruin your day. It's more than okay to be confident, but when a person begins to think too highly of themselves, it can cause problems in their relationships as well as in their every day life.
Understand their issue(s). It's important to realize that often people who are boastful and/or overly confident are generally people with low self-esteem and have a need to make themselves feel better by making others feel lower than themselves by their actions and words. Understanding that it's not always necessarily that they think so highly of themselves, but really need to learn to love themselves will help you not to get so frustrated and angry with them.
Give honor where honor is due when they perform and do something well.
Be honest with them in a caring way during the times they ask for your advice about whether they are "the best" and in a bragging mode. This would be a good time to try to talk to the overly confident person about their attitude and behavior and especially if it's a child, by explaining to them that no one will be the absolute best at everything at all times and that it's very important to learn not to be a sore loser, but a good "team player" when they are not winning at something.
If the overly confident person does not respond well to your advice, be patient with them, but you may need to pull away for your own good and peace of mind.
Communicate with them calmly and stay humble. The overly confident person just may be watching you and may be impressed causing them to eventually be influenced positively by your humility.