Think-pair-share (TPS) is a classroom active learning strategy in which students work on activities, first individually, then in pairs and finally as the whole class. TPS allows students to express their reasoning, reflect on their understanding and obtain prompt feedback on their learning. While TPS is recommended to foster classroom engagement and learning, there is a lack of research based evidence in computer science education on the benefits of TPS for learning. In this study, we investigate the learning effectiveness of TPS in a CS1 course. We performed a quasi-experimental study and found that students who learned via TPS performed significantly better on a post-test than students who learned the same concept via lecture. We also conducted a survey and focus group interviews to understand student perceptions of learning with TPS. The majority of students agreed that TPS activities helped improve their conceptual understanding. From an instructor's point of view, TPS was useful to address the challenges of a large class, such as students tuning out or getting distracted and was easy to implement even in a large class.