Cocksure implies excessive confidence that could lead to mistakes or embarrassment if you're wrong. He was cocksure that his answer was correct, but it actually resulted in an awkward mistake.
Pro Tip 2/3
Negative Connotation
While confident is positive, cocksure often has a negative shade, suggesting arrogance or heedlessness. Her cocksure attitude during the interview may have seemed disrespectful to the panel.
Pro Tip 3/3
Cultural Interpretation
Be aware that in some cultures, being cocksure may be considered rude or offensive, not just confident. He didn't realize how his cocksure remarks would come off as offensive to the audience.