Virginia quarterback Matt Johns (15) throws a pass during the second half of an NCAA college football game in Charlottesville, Va., Saturday, Nov. 12, 2016. Miami defeated Virginia 34-14. (Ryan M. Kelly/The Daily Progress via AP) (Ryan M. Kelly/AP)

Staring down the final three months of a five-year college career at Virginia, Matt Johns motivated himself with a simple message.

“Keep going, keep going, keep going,” he reminded himself.

For many, that would have been easier said than done. The quarterback had persevered through a coaching change only to lose his starting job to Kurt Benkert and ended up leading the scout team after senior Connor Brewer was named the backup. For the first time in two years, Johns was off the two-deep, his primary responsibilities leading the scout-team offense against Coach Bronco Mendenhall’s defense in practice.

He kept going as if nothing had changed.

Johns relentlessly studied game plans each week when he could have been taking it easier in his final year in Charlottesville. He used practice to hone his skills and meticulously broke down opposing defenses, never expecting playing time but preparing for it just the same.

Now, as the Cavaliers (2-9, 1-6 ACC) face their season finale against rival Virginia Tech in Blacksburg, it seems Johns’s preparation has paid off.

“I just put my head down and kept working,” Johns said, “and it led me to this situation.”

The situation is that of Virginia’s starting quarterback Saturday against the Hokies (8-3, 5-2). Mendenhall named Johns the starter ahead of last week’s loss at Georgia Tech following a four-game slide in production from Benkert. The transfer junior threw six touchdown passes to four interceptions in his final four games as starter, which ended with him getting sacked six times against Miami.

Citing ball security issues and the pressing need to have Benkert “take a step back,” Mendenhall called on Johns.

“I think he’s earned the chance through not only his career here but the season in leading our scout-team offense and how unselfish he’s been battling his way to back into contention at quarterback,” Mendenhall said early last week. “And I think it’s not only the right thing to do, I think it’s the fair thing to do. I think it’s the best thing for our team.”

In running his defense, Mendenhall observed Johns’s work with the scout team every day. But what made the decision an easy one for the first-year head coach was Johns’s leadership.

By the time Mendenhall arrived in Charlottesville, Johns was a veteran leader in a program that had seen its fair share of tumult over the past five years.

Johns had arrived in 2012 battling for playing time just as he would as a senior, sitting in a crowded quarterback room that included David Watford, Michael Rocco, Phillip Sims and Greyson Lambert. Mendenhall learned Johns’s story — how as a redshirt sophomore he had stepped up when called on to relieve Lambert in the last 1:20 of the second quarter against then-No. 7 UCLA in Scott Stadium.

He knew Johns had started every game in 2015 and praised Coach Mike London on the way out. He also welcomed Mendenhall, “buying in” to a cultural reformation.

“I have to let Matt have his chance,” Mendenhall said last week. “He’s done way too much for the program and he’s competed in such a manner where that’s got to happen, just from my standpoint as the head coach.”

Johns never lobbied for playing time this year. He saw spurts of action against Oregon, North Carolina and Miami before starting in last week’s loss to Georgia Tech, in which he completed 27 of 44 attempts and threw for 220 yards and a touchdown. Behind a feeble offensive line, he was sacked three times.

This week he got back to work. And having earned the chance to start his final game as a Cavalier, Johns allowed a little time to reflect on the past five years as well.

“It’s really about belief: When you buy into what the coaches are preaching, it’ll eventually pay off,” Johns said Wednesday. “It might not be in football, but there’s going to be something in life where it will pay off. Fortunately for me, it was playing again. In my head, I knew that that wasn’t guaranteed. I was never guaranteed to play again. But it was a matter of sticking to what they’re preaching — they’re values that I believe in in life. It’s much bigger than football.”