The trial of Oscar Pistorius has heard that the athlete was aware of South African firearms and self-defence laws that say you cannot shoot at an intruder unless your life is in danger.
The South African Olympic and Paralympic athlete is on trial for the murder of girlfriend Reeva Steenkamp in 2013.
Testifying on day 11 of the trial, firearms instructor Sean Rens read out a gun licence test passed by the track athlete.
Mr Pistorius shot dead Ms Steenkamp through a locked toilet door at his Pretoria home on Valentine's Day last year.
One of the questions asked whether a homeowner was allowed to open fire on burglars on the other side of a security gate.
Mr Pistorius answered: "No", Mr Rens, who taught Mr Pistorius gun safety and sold him weapons, told the court.
Asked in the test about the legal basis for using lethal force, Mr Pistorius answered: "The attack must be against you, a person and be unlawful."
In answer to another scenario, Mr Pistorius replied: "No, life is not in danger."
Mr Pistorius also made clear that a gun-owner should never shoot unless he knew what he was shooting at, and what lay behind the target: "Know your target and what lies beyond," Mr Rens said, quoting Mr Pistorius' answer.
The Paralympic gold medallist denies the murder charge, saying he shot Ms Steenkamp in a tragic accident after mistaking her, through the door, for a night-time intruder.
Mr Rens also told the court of an incident, related to him by Mr Pistorius, in which the athlete heard noises in his house and went into "code-red or combat mode" only to find the source of the disturbance was a washing machine.
At the time, Mr Pistorius joked on his Twitter account of having gone into "full attack recon mode in the pantry" after thinking an intruder was in his home.
Mr Rens also testified that Mr Pistorius had ordered seven firearms - including an assault rifle and a Smith and Wesson 500 revolver, one of the world's most powerful handguns – although the orders were cancelled shortly after Ms Steenkamp's death.
The testimony is likely to back the prosecution's attempts to depict Mr Pistorius as a gun-obsessed hot-head.
If found guilty of murder, Mr Pistorius faces at least 25 years behind bars.