Ideally a specific contract for the limited purpose of the interview would determine this. Such a contract could assign such "test" works to either the prospective employer or to the prospective employee, as the parties choose.
In the absence of a specific written agreement (to effect a transfer of copyright, an agreement must be in writing and signed) the copyright on such a work will belong to the prospective employee under 17 USC 201 (a) unless the work counts as a work made for hire. 17 USC 201 reads in relevant part:
(a) Initial Ownership.—Copyright in a work protected under this title vests initially in the author or authors of the work. The authors of a joint work are coowners of copyright in the work.
(b) Works Made for Hire.—In the case of a work made for hire, the employer or other person for whom the work was prepared is considered the author for purposes of this title, and, unless the parties have expressly agreed otherwise in a written instrument signed by them, owns all of the rights comprised in the copyright.
According to 17 USC 101
A “work made for hire” is—
(1) a work prepared by an employee within the scope of his or her employment; or
(2) a work specially ordered or commissioned ... if the parties expressly agree in a written instrument signed by them that the work shall be considered a work made for hire. ...
Since we are assuming the absence of a written agreement, only part (1) of this applies. Thus the status of the work depends entirely on whether the programmer is an "employee".
The mere fact that a person recessives compensation does not make that person an employee. For copyright purposes, agency law applies. Specifically:
The US Copyright office Circular 09 "Works Made for Hire" states:
To help determine who is an employee, the Supreme Court in
Community for Creative Non-Violence v. Reed identified factors that make up an “employer-employee” relationship as defined by
agency law. The factors fall into three broad categories.
- Control by the employer over the work. For example, the
employer determines how the work is done, has the work
done at the employer’s location, and provides equipment
or other means to create the work.
- Control by employer over the employee. For example, the
employer controls the employee’s schedule in creating the
work, has the right to have the employee perform other
assignments, determines the method of payment, or has
the right to hire the employee’s assistants.
- 3 Status and conduct of employer. For example, the
employer is in business to produce such works, provides
the employee with benefits, or withholds tax from the
employee’s payment.
These factors are not exhaustive. The Court left unclear
which of these factors must be present to establish the
employment relationship under the work-for-hire definition.
Moreover, it held that supervision or control over creation of
the work alone is not controlling.
However, all or most of these factors characterize a regular,
salaried employment relationship, and it is clear that a work
created within the scope of such employment is a work made
for hire (unless the parties involved agree otherwise).
Examples of works made for hire created in an employment relationship include:
- A software program created by a staff programmer within
the scope of his or her duties at a software firm [Emphasis added]
...
The closer an employment relationship comes to regular,
salaried employment, the more likely it is that a work created
within the scope of that employment will be a work made for
hire. But because no precise standard exists for determining
whether a work is made for hire under part 1 of the definition in section 101 of the copyright law, consultation with a
lawyer may be advisable.
If a work is made for hire, the employer or other person
for whom the work was prepared is the author and should
be named as the author on the application for copyright registration. Respond “yes” to the question on the application
about whether the work is made for hire
The Wikipedia article aboutCommunity for Creative Non-Violence v. Reed 490 U.S. 730 (1989) describes the case, in whioh a charity hired a sculptor to produce " statue that depicted the plight of homeless people for a Christmas pageant in Washington DC". CCNV claimed that the statute's copyright was theirs as a work made for hire (WMFH). Sculptor Reid claimed the copyright as being the author
Justice Thurgood Marshall wrote in the majority opinion [Footnotes omitted]:
The Copyright Act of 1976 provides that copyright ownership "vests initially in the author or authors of the work." 17 U.S.C. § 201(a). As a general rule, the author is the party who actually creates the work, that is, the person who translates an idea into a fixed, tangible expression entitled to copyright protection. § 102. The Act carves out an important exception, however, for "works made for hire."
<
...
[Page 490 U. S. 740] In the past, when Congress has used the term "employee" without defining it, we have concluded that Congress intended to describe the conventional master-servant relationship as understood by common law agency doctrine. See, e.g., Kelley v. Southern Pacific Co., 419 U. S. 318, 419 U. S. 322-323 (1974); Baker v. Texas & Pacific R. Co., 359 U. S. 227, 359 U. S. 228 (1959) (per curiam); Robinson v. Baltimore & Ohio R. Co., 237 U. S. 84, 237 U. S. 94 (1915). Nothing in the text of the work for hire provisions indicates that Congress used the words "employee" and "employment" to describe anything other than "the conventional relation of employer and employe.'" Kelley, supra, at 419 U. S. 323, quoting Robinson, supra, at 237 U. S. 94; ... On the contrary, Congress' intent to incorporate the agency law definition is suggested by § 101(1)'s use of the term, "scope of employment," a widely used term of art in agency law. See Restatement (Second) of Agency § 228 (1958) (hereinafter Restatement). ... We thus agree with the Court of Appeals that the term "employee" should be understood in light of the general common law of agency.
...
[Page 490 U. S. 751-2] In determining whether a hired party is an employee under the general common law of agency, we consider the hiring party's right to control the manner and means by which the product is accomplished. Among the other factors relevant to this inquiry are the skill required; the source of the instrumentalities and tools; the location of the work; the duration of the relationship between the parties; whether the hiring party has the right to assign additional projects to the hired party; the extent of the hired party's discretion over when and how long to work; the method of payment; the hired party's role in hiring and paying assistants; whether the work is part of the regular business of the hiring party; whether the hiring party is in business; the provision of employee benefits; and the tax treatment of the hired party. See Restatement § 220(2) (setting forth a nonexhaustive list of factors relevant to determining whether a hired party is an employee). No one of these factors is determinative. See Ward, 362 U.S. at 362 U. S. 400; Hilton Int'l Co. v. NLRB, 690 F.2d 318, 321 (CA2 1982).
Conclusion
An applicant being given a "test project" as part of an employment interview is probably not an employee under agency law. Thus the work is not a WMFH, an, in the absence of a written agreement to assign the work created as part of the test to the prospective employer, the copyright would belong to the prospective employee.
I have not found a case specifically relating to this interview fact pattern, and it could be that a court would rule otherwise in this specific pattern.