A virus is a type of malware that replicates by attaching itself to other host files or programs. In contrast, worms are standalone programs that propagate across networks without a host file, and Trojans rely on deception rather than self-replication.