Arnav Bansal returned home last spring after taking his Advanced Placement computer science exam feeling hopeful.

Sometimes, Bansal would walk away from a test, stumped by certain questions. This time, he thought he did well enough to receive a 5, the maximum score. He thought he might even have answered every question correctly, the 15-year-old recalled telling his parents.

“I was pretty confident I did well,” Bansal said, “There was, surprisingly, a small feeling inside of me.”

In the summer, Bansal checked his score online and confirmed his initial hunch — he had received a 5 on the test. Months later, a letter and email arrived from the College Board notifying Bansal that he had, indeed, attained a perfect score.

It was a feat made more remarkable given that four of Bansal’s classmates at Thomas Jefferson High School for Science and Technology, an elite admissions-based public school in Fairfax County, had done the same.

Just 112 students in the world — fewer than 1 percent of all students who took the AP Computer Science A exam last year — answered every question correctly, according to the College Board, which owns, writes and administers the exam. It was the most students at any high school to perform flawlessly on any Advanced Placement science or technology test last year.

“These students’ success is a testament not only to their hard work and dedication, but to the excellent instruction they received from their AP teachers,” said Trevor Packer, a senior vice president at College Board.

The AP Computer Science A exam assesses students’ understanding of the Java programming language. It consists of 40 multiple-choice questions that quiz students on algorithms, software and programming fundamentals as well as a section intended to measure problem-solving ability.

Most Thomas Jefferson students take computer science, a required class, as freshmen, said Ria Galanos, a computer science teacher at the school. Students who enroll in AP computer science tend to already enjoy the material, she said.

Galanos said teachers encourage students to do the best they can and don’t push for perfection. But, she said, “it’s a nice little achievement” when students receive a perfect score.

All Thomas Jefferson students who took the AP computer science exam last year received at least a 3, which means students have demonstrated they are capable of introductory, college-level work in the subject. The average score on the exam for the school’s students was 4.8, said Nicole Kim, another computer science teacher.

Kim said this isn’t the first time five students at the school answered every question on the test correctly. The College Board began notifying students and schools about perfect AP exam scores in 2015, a College Board spokeswoman said.

Students enrolled in the school’s AP computer science class work on daily programming assignments and are tested every two or three weeks. Questions on those tests are more challenging than questions posed on the AP exam, Kim said.

The rigor of the school’s curriculum helped Joshua Sahaya Arul, 17, feel confident before the test. Sahaya Arul said he didn’t have to study for the exam much. Still, he didn’t expect a perfect score.

“I had a pretty good feeling I did well. I didn’t know that I did everything right,” the high school senior said.

The son of two computer scientists, Sahaya Arul said he wasn’t always drawn to the subject. Taking computer science wasn’t a priority, but he grew fond of the subject once he did. He plans to study computer science at the University of Virginia.

“It really comes down to the logic behind it,” Sahaya Arul said. “It’s, in some ways, straightforward.”