---
title: "Computer Virus — AP CSP Definition & Exam Guide"
description: "A computer virus is malicious code that copies itself by attaching to legitimate programs. Learn how AP CSP Topic 5.6 tests viruses, malware, and safe computing."
canonical: "https://fiveable.me/ap-comp-sci-p/key-terms/computer-virus"
type: "key-term"
subject: "AP Computer Science Principles"
unit: "Unit 5"
---

# Computer Virus — AP CSP Definition & Exam Guide

## Definition

In AP Computer Science Principles, a computer virus is a malicious program that can copy itself and gain unauthorized access to a computer, often by attaching to legitimate programs so it spreads whenever those programs run or get shared (Topic 5.6, Safe Computing).

## What It Is

A computer virus is malicious code with two defining behaviors. First, it copies itself. Second, it spreads by attaching to legitimate programs, so when you run or share an infected file, you spread the virus too, often without realizing it. That self-replication is what makes it a *virus* and not just any [harmful](/ap-comp-sci-p/unit-5/beneficial-harmful-effects/study-guide/rErWKPcu55DLj7N7L8hZ "fv-autolink") [program](/ap-comp-sci-p/unit-1/program-function-purpose/study-guide/8hL8KatG4rAWTwZSglGB "fv-autolink").

The attachment trick is the part the AP exam cares about most. Because the virus rides along inside files that look trustworthy, normal caution ("I only download real software") isn't enough protection on its own. And once a virus has copied itself into multiple programs on a system, deleting the original infected file doesn't stop it. The copies keep spreading. Viruses fall under the broader category of [malware](/ap-comp-sci-p/key-terms/malware "fv-autolink"), which is any software designed to damage a system or take partial control of it, and they're one of the main ways unauthorized access happens in Topic 5.6.

## Why It Matters

Computer viruses live in **[Unit 5](/ap-comp-sci-p/unit-5 "fv-autolink"): Impact of Computing, Topic 5.6 (Safe Computing)**. They support two learning objectives directly. **[AP Comp Sci P](/ap-comp-sci-p "fv-autolink") 5.6.B** asks you to explain how computing resources can be protected and misused, and viruses are the classic misuse example, with protections like keeping software updated and avoiding untrusted downloads. **AP Comp Sci P 5.6.C** asks you to explain how unauthorized access is gained, and a virus is one of the answers, alongside phishing, keylogging, and rogue access points. Unit 5 is the "big picture" unit on the exam, and safe computing questions show up reliably in the multiple-choice section. Knowing exactly what makes a virus a virus (self-replication plus attachment) lets you pick the right answer when the choices all sound vaguely "bad software."

## Connections

### [Malware (Unit 5)](/ap-comp-sci-p/key-terms/malware)

Malware is the umbrella category and a virus is one specific type. Every virus is malware, but not all malware is a virus. The virus's signature move, copying itself by attaching to legitimate programs, is what earns it the name.

### [Phishing (Unit 5)](/ap-comp-sci-p/key-terms/phishing)

[Phishing](/ap-comp-sci-p/key-terms/phishing "fv-autolink") and viruses are both unauthorized-access tools under 5.6.C, but they attack different targets. Phishing tricks the human into handing over information, while a virus exploits the software itself. A phishing email is also a common delivery vehicle for a virus-infected attachment.

### [Keylogging (Unit 5)](/ap-comp-sci-p/key-terms/keylogging)

A keylogger records every keystroke to steal passwords and confidential information. Viruses often install keyloggers as their payload, so the virus is the delivery [method](/ap-comp-sci-p/key-terms/procedure "fv-autolink") and the keylogger is what does the actual data theft.

### [Multifactor Authentication (Unit 5)](/ap-comp-sci-p/key-terms/multifactor-authentication)

MFA is the protection side of 5.6.B. Even if a virus or keylogger steals your password, MFA requires a second piece of evidence (like a code on your phone), which limits how much damage one stolen credential can do.

## On the AP Exam

Viruses show up in the multiple-choice section, usually in scenario form. A typical stem describes an infected system and asks you to explain the mechanism, like why a virus can keep spreading even after the original infected program is deleted (because it already copied itself into other programs). Another common angle is prevention: questions ask which technique would be least effective at stopping infections through legitimate-looking downloads, testing whether you understand that viruses hide inside trusted files. You need to do three things with this term. Define it by its self-copying, attaching behavior. Classify it correctly as a type of malware. And connect it to protections like updated software, careful downloading, and authentication measures. There's no FRQ on the current AP CSP exam beyond the Create task, so all of this is MCQ territory.

## computer virus vs Malware

Malware is any software intended to damage a computing system or take partial control of its operations. A computer virus is one specific kind of malware, defined by how it spreads: it copies itself and attaches to legitimate programs. If an exam answer choice describes harmful software that doesn't self-replicate, it's malware but not necessarily a virus. When a question stresses copying, attaching, or spreading, it's pointing at a virus specifically.

## Key Takeaways

- A computer virus is a malicious program that copies itself and gains unauthorized access, usually by attaching to legitimate programs.
- A virus is one type of malware, so every virus is malware but not all malware is a virus.
- Because a virus copies itself into other programs, deleting the original infected file doesn't stop it from spreading.
- Viruses spread through downloads and shared files that look legitimate, which is why 'only download from trusted sources' alone isn't a complete defense.
- On the AP exam, viruses fall under Topic 5.6 (Safe Computing) and learning objectives 5.6.B and 5.6.C, alongside phishing, keylogging, and rogue access points.
- Protections include keeping software updated, avoiding suspicious downloads and attachments, and using strong authentication like MFA.

## FAQs

### What is a computer virus in AP Computer Science Principles?

It's a malicious program that copies itself and gains [unauthorized access](/ap-comp-sci-p/unit-5/safe-computing/study-guide/zMi0PutBHnDjIlOB5lMs "fv-autolink") to a computer, often by attaching to legitimate programs. It's tested in Topic 5.6 (Safe Computing) in Unit 5.

### What's the difference between a computer virus and malware?

Malware is the broad category of any software designed to damage a system or take control of it. A virus is one specific type of malware that spreads by copying itself and attaching to legitimate programs. The self-replication is the defining feature.

### Does deleting an infected program remove a computer virus?

Not necessarily. Because the virus copies itself, it may have already attached to other programs on the system, so deleting the original infected file doesn't stop the copies from spreading. This exact scenario shows up in AP CSP practice questions.

### Can you get a virus from a legitimate software download?

Yes. Viruses attach to legitimate programs, so an infected copy of real software can still spread the virus. That's why exam questions test layered defenses like verified download sources, software updates, and antivirus scanning rather than trust in a single source.

### Is a computer virus the same thing as phishing?

No. Phishing tricks a person into giving up personal information, like a fake login page stealing your password. A virus is software that infects and copies itself through programs. Both are ways unauthorized access happens under learning objective 5.6.C, but one targets people and the other targets systems.

## Related Study Guides

- [5.6 Safe Computing](/ap-comp-sci-p/unit-5/safe-computing/study-guide/zMi0PutBHnDjIlOB5lMs)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-p/key-terms/computer-virus#resource","name":"Computer Virus — AP CSP Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-p/key-terms/computer-virus","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-p/key-terms/computer-virus#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T05:53:25.436Z","isPartOf":{"@type":"Collection","name":"AP Computer Science Principles Key Terms","url":"https://fiveable.me/ap-comp-sci-p/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-p/key-terms/computer-virus#term","name":"computer virus","description":"In AP Computer Science Principles, a computer virus is a malicious program that can copy itself and gain unauthorized access to a computer, often by attaching to legitimate programs so it spreads whenever those programs run or get shared (Topic 5.6, Safe Computing).","url":"https://fiveable.me/ap-comp-sci-p/key-terms/computer-virus","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science Principles Key Terms","url":"https://fiveable.me/ap-comp-sci-p/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a computer virus in AP Computer Science Principles?","acceptedAnswer":{"@type":"Answer","text":"It's a malicious program that copies itself and gains [unauthorized access](/ap-comp-sci-p/unit-5/safe-computing/study-guide/zMi0PutBHnDjIlOB5lMs \"fv-autolink\") to a computer, often by attaching to legitimate programs. It's tested in Topic 5.6 (Safe Computing) in Unit 5."}},{"@type":"Question","name":"What's the difference between a computer virus and malware?","acceptedAnswer":{"@type":"Answer","text":"Malware is the broad category of any software designed to damage a system or take control of it. A virus is one specific type of malware that spreads by copying itself and attaching to legitimate programs. The self-replication is the defining feature."}},{"@type":"Question","name":"Does deleting an infected program remove a computer virus?","acceptedAnswer":{"@type":"Answer","text":"Not necessarily. Because the virus copies itself, it may have already attached to other programs on the system, so deleting the original infected file doesn't stop the copies from spreading. This exact scenario shows up in AP CSP practice questions."}},{"@type":"Question","name":"Can you get a virus from a legitimate software download?","acceptedAnswer":{"@type":"Answer","text":"Yes. Viruses attach to legitimate programs, so an infected copy of real software can still spread the virus. That's why exam questions test layered defenses like verified download sources, software updates, and antivirus scanning rather than trust in a single source."}},{"@type":"Question","name":"Is a computer virus the same thing as phishing?","acceptedAnswer":{"@type":"Answer","text":"No. Phishing tricks a person into giving up personal information, like a fake login page stealing your password. A virus is software that infects and copies itself through programs. Both are ways unauthorized access happens under learning objective 5.6.C, but one targets people and the other targets systems."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science Principles","item":"https://fiveable.me/ap-comp-sci-p"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-p/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 5","item":"https://fiveable.me/ap-comp-sci-p/unit-5"},{"@type":"ListItem","position":4,"name":"computer virus"}]}]}
```
