
191 Cal.App.3d 559 (1987)
236 Cal. Rptr. 577
R.M. SHERMAN CO., INC., Plaintiff, Cross-defendant and Appellant,
v.
W.R. THOMASON, INC., Defendant, Cross-complainant and Respondent; INDUSTRIAL INDEMNITY COMPANY, Defendant and Respondent. R.M. SHERMAN CO., INC., Plaintiff, Cross-defendant and Respondent,
v.
W.R. THOMASON, INC., Defendant, Cross-complainant and Appellant; INDUSTRIAL INDEMNITY COMPANY, Defendant and Appellant.
Docket Nos. A034219, A035076.
Court of Appeals of California, First District, Division Four.
April 28, 1987.
*561 COUNSEL
A. Charles Dell'Ario for Plaintiff, Cross-defendant and Appellant and Plaintiff, Cross-defendant and Respondent.
Graham & James and Edward K. Allison for Defendant, Cross-complainant and Respondent and Defendant, Cross-complainant and Appellant and for Defendant and Appellant and Defendant and Respondent.
[Opinion certified for partial publication.[*]]
OPINION
CHANNELL, J.
Plaintiff R.M. Sherman Co., Inc. (Sherman) sued for money due under a building contract between it, as subcontractor, and defendant W.R. Thomason, Inc. (Thomason), as prime contractor. Also named as a defendant was Industrial Indemnity Company, the surety under a stop notice release bond. The trial court allowed Thomason to assert a defense of setoff based on a previous contract between Sherman and Thomason which violated the Subletting and Subcontracting Fair Practices Act (former Gov. Code, § 4100 et seq.; now Pub. Contract Code, § 4100 et seq.).[1] (Hereafter, Fair Practices Act.) We hold that this was error.

I. FACTS.
In December 1981, Thomason agreed to subcontract to Sherman the concrete work on a public improvement project in the City of Ukiah. Thomason had already secured the prime contract without identifying a *562 subcontractor. The City was not told of, and did not approve, Sherman's involvement in the project. As part of the transaction some of Sherman's employees and suppliers were paid through Thomason's accounts, apparently to conceal Sherman's involvement.[2] Due to inclement weather, Thomason incurred cost overruns of some $99,000, which it contended Sherman was obligated to pay.
In September 1982 the parties entered into a second, unrelated agreement making Sherman a subcontractor on a public works project in the City of Pleasanton. So far as the record indicates this subcontract was entirely lawful. Thomason withheld part of the proceeds of this contract, claiming a setoff based on its demands under the Ukiah contract.
Sherman filed this action to recover the sums withheld by Thomason. Thomason cross-complained for damages under the Ukiah contract. Sherman answered the cross-complaint, asserting that the Ukiah contract was illegal and unenforceable. Sherman then moved for summary judgment or summary adjudication of the proposition that the relief available on the cross-complaint was limited to the amount due Sherman in the main action. The trial court declared the Ukiah contract illegal and "void," but denied summary judgment and declared that Thomason "may set off its Ukiah claim" against Sherman's claim.[3] Sherman then amended its answer to plead an estoppel to assert the Ukiah demands.
The parties stipulated for purposes of trial that Thomason's setoff exceeded the size of Sherman's own claim. The apparent intent was to obviate all dispute over the setoff except with respect to the effect of the illegality of the contract and the question of estoppel. The right to pursue those issues on appeal was expressly reserved. Since the first question had already been adjudicated, there were three issues left for trial: (1) whether Thomason was estopped to assert the setoff; (2) whether Industrial, as surety, could avail itself of the setoff; and (3) whether Sherman was owed some $5,000 beyond the $22,365.35 conceded by Thomason.
*563 After a nonjury trial on these issues, the court entered judgment declaring that Sherman was entitled to the amount prayed for, that Thomason was entitled to a setoff in a like amount, and that each party should take nothing. On cross-motions under Civil Code section 1717, the court found Sherman to be the prevailing party and awarded him attorney fees. Sherman appealed from the adverse portions of the judgment, and Thomason appealed from the fee award.

II. ANALYSIS.
(1a) The Ukiah contract violated sections 4106 and 4107 of the Fair Practices Act by assigning work, without the City's consent, to a subcontractor who was not identified in the bid for the prime contract.[4] Civil Code sections 1598 and 1608 make a contract "void" if it has an unlawful object or an unlawful consideration. The Ukiah contract appeared to have both  the unlawful participation by Sherman being both the object of the contract and the consideration for Thomason's counterperformance. It would therefore appear that the contract was "void." Thomason appears to concede as much.
(2) If the contract was truly void it created no right or claim whatsoever: "A void contract is no contract at all; it binds no one and is a mere nullity." (Guthman v. Moss (1984) 150 Cal. App.3d 501, 507 [198 Cal. Rptr. 54].) "No rights are enforceable under a void contract." (A-Mark Coin Co. v. General Mills, Inc. (1983) 148 Cal. App.3d 312, 322 [195 Cal. Rptr. 859]; see First Nat. Bk. v. Thompson (1931) 212 Cal. 388, 405-406 [298 P. 808] [contract void due to illegality "has no legal existence for any purpose"]; Tiedje v. Aluminum Taper Milling Co. (1956) 46 Cal.2d 450, 453-454 [296 P.2d 554] [illegal contract "may not serve as the foundation of any action, either at law or in equity"].) If the agreement conferred no rights whatsoever and is a legal nullity, it is difficult to perceive how it could furnish the basis for a setoff. (3) The general rule is that a setoff must rest on a claim enforceable in its own right. (20 Am.Jur.2d, Counterclaim, Recoupment, and Setoff, §§ 34, 55, pp. 256-257, 273-274.)
*564 Unfortunately, the issue before us does not permit such a straightforward analysis. "The illegality of contracts constitutes a vast, confusing and rather mysterious area of the law." (Strong, The Enforceability of Illegal Contracts (1961) 12 Hastings L.J. 347.) "One of the reasons for the apparent confusion is the fact that illegality may appear in many forms and in varying degrees.... Another source of confusion seems to be the tendency of some courts to speak in terms of absolute rules, and others in terms of numerous exceptions. Unfortunately, there appear to be several conflicting and competing `absolute' rules. On the other hand, a monotonous and patterned recital of exceptions is apt to obscure the actual rule of decision." (Id. at p. 348.)
Civil Code sections 1598 and 1608 are not always applied literally; in many cases they have simply been overlooked or ignored. (E.g., Asdourian v. Araj (1985) 38 Cal.3d 276, 293 [211 Cal. Rptr. 703, 696 P.2d 95] [suggesting contract might be merely "voidable"; allowing recovery despite violation punishable as misdemeanor].) In any event the courts have fashioned exceptions and qualifications to the seemingly unequivocal statutory mandate of unenforceability. (E.g., Asdourian v. Araj, supra, 38 Cal.3d 276, 292-294 [defendant unjustly enriched, plaintiff unduly penalized]; Lewis & Queen v. N.M. Ball Sons (1957) 48 Cal.2d 141, 151 [308 P.2d 713] [policy of violated statute better served by granting relief]; Severance v. Knight-Counihan Co. (1947) 29 Cal.2d 561, 569 [177 P.2d 4, 172 A.L.R. 1107] [restitution to party only slightly at fault, or party equally at fault who repudiates before illegal part of bargain executed]; see Rest.2d Contracts, §§ 178, 180, 181, 183, 184, 198, 199.)
Here Thomason has relinquished any claim to affirmative relief based on the illegal contract. This is consistent with the one reported case to consider the issue, which declares that a contractor who enters an agreement in violation of the Fair Practices Act cannot recover for its breach by the subcontractor. (Kiely Corp. v. Gibson (1964) 231 Cal. App.2d 39 [41 Cal. Rptr. 559].)
Thomason, however, contends that Sherman's breach of the Ukiah contract affords the basis for a setoff. This argument rests on a supposed analogy to cases permitting an unlicensed contractor to assert a setoff based on a contract for building services, notwithstanding that the contract is otherwise unenforceable due to the absence of a license.[5] (Marshall v. Von Zumwalt (1953) 120 Cal. App.2d 807 [262 P.2d 363]; Steinwinter v. Maxwell (1960) 183 Cal. App.2d 34 [6 Cal. Rptr. 496]; Dahl-Beck Electric Co. v. Rogge *565 (1969) 275 Cal. App.2d 893 [80 Cal. Rptr. 440]; S & Q Construction Co. v. Palma Ceia Development Organization (1960) 179 Cal. App.2d 364 [3 Cal. Rptr. 690]; Culbertson v. Cizek (1964) 225 Cal. App.2d 451, 473 [37 Cal. Rptr. 458].)
(4) The analogy is unsound. Generally, where a statute prohibits or penalizes specified conduct, the courts will infer a prohibition on enforcement of contracts based on such conduct. (Reid v. Overland Machined Products (1961) 55 Cal.2d 203, 208 [10 Cal. Rptr. 819, 359 P.2d 251]; Smith v. Bach (1920) 183 Cal. 259, 262-263 [191 P. 14]; Gruzen v. Henry (1978) 84 Cal. App.3d 515, 518 [148 Cal. Rptr. 573]; Severance v. Knight-Counihan Co., supra, 29 Cal.2d 561, 568.) In the context of licensing statutes, however, a contrary rule has been said to apply, namely, that when penalties are provided by statute, the courts "will not impose additional penalties for noncompliance with the licensing requirement." (Vitek, Inc. v. Alvarado Ice Palace, Inc. (1973) 34 Cal. App.3d 586, 592 [110 Cal. Rptr. 86]; contra, Owen v. Off (1951) 36 Cal.2d 751, 753 [227 P.2d 457].) This exception to the general rule appears to rest, at least in part, on an application of the principle expressio unius exclusius alterius est (to express one thing is to exclude another). (See Vitek, Inc. v. Alvarado Ice Palace, Inc., supra, 34 Cal. App.3d 586, 593.) Thus in Marshall v. Von Zumwalt, supra, 120 Cal. App.2d 807, 810, the court quoted Business and Professions Code section 7031 and observed, "the statute merely prohibits a contractor from maintaining or bringing an action.... It does not prohibit him when sued from setting up as a defense any sums which may be equitably due him from the plaintiff upon such illegal contract." (See also S & Q Construction Co., supra, 179 Cal. App.2d 364, 367; Steinwinter v. Maxwell, supra, 183 Cal. App.2d 34, 39.)
The Fair Practices Act contains no such arguably exclusive remedy. If anything, it implies that a noncomplying contract creates rights only in the subcontractor. Section 4112 recognizes that the subcontractor may sue under the contract, but provides that illegality is no defense to the contractor.[6] This implies legislative recognition of the general rule of unenforceability, and that under the rule of expressio unius the contract is in all other respects subject to that rule. (See Kiely Corp. v. Gibson, supra, 231 Cal. App.2d at p. 46.) The Legislature presumably foresaw that situations might arise where cross-demands would exist. Yet while permitting the subcontractor to sue, it impliedly excluded a reciprocal right in the contractor and, at least arguably, any defense predicated on such a right. The Legislature is familiar with setoff defenses and knows how to expand them beyond the scope of affirmatively prosecutable claims when it chooses to do so. (See Code Civ. Proc., *566 § 431.70 [allowing setoff on some cross-demands otherwise barred by the statute of limitations].) It plainly intended the burden of noncompliance with the Fair Practices Act to rest squarely on the contractor as the party with the best ability to secure compliance, regardless of any seeming inequities which might result.
The unlicensed contractor cases do not rest solely on a theory of expressio unius. The Marshall court also justified allowing a setoff by observing that the contract was "not malum in se but merely malum prohibitum," and that the case presented "no question of public interest or public policy" but was merely "a matter of balancing the rights and equities between the parties." (120 Cal. App.2d at p. 810.) No reasoning was given and no authority cited for the assertion that the contract was malum prohibitum, and it is unclear what conclusion was drawn from that premise.[7] Nor did the court explain its view that there was no issue of public interest or policy involved. (See Asdourian v. Araj, supra, 38 Cal.3d 276, 282 [purpose of contractor's licensing statutes is to guard public against consequences of incompetent workmanship, imposition and deception]; Norwood v. Judd (1949) 93 Cal. App.2d 276, 286 [209 P.2d 24] [enacted "primarily for the protection and safety of the public"].) Perhaps the unspoken rationale is that where a licensing statute is enacted for the protection of private economic interests (such as the interest of property owners in competent construction), and where a contract in violation of that statute has been substantially performed, a member of the protected class will not be permitted to repudiate his or her own undertakings behind the shield of the statutory violation while seeking affirmative relief in connection with the same transaction.
So understood, the unlicensed contractor cases remain wholly inapposite here. The Fair Practices Act is addressed to the efficient and economical supervision of public works projects and is not solely, or even primarily, for the protection of private interests. Courts have long held that a purpose of the act is to ensure that the contracting authority  the public agency involved  has an opportunity to investigate and approve any subcontractor who is proposed to work on the project. (Fred J. Early, Jr., Co. v. County *567 Sanitation Dist. (1963) 214 Cal. App.2d 505, 507 [29 Cal. Rptr. 633]; Klose v. Sequoia Union High School Dist. (1953) 118 Cal. App.2d 636, 640 [258 P.2d 515]; see Kiely Corp. v. Gibson, supra, 231 Cal. App.2d 39, 44-45.) In 1963 the Legislature enacted section 4101 of the Fair Practices Act, which provides, "The Legislature finds that the practices of bid shopping and bid peddling in connection with the construction, alteration, and repair of public improvements often result in poor quality of material and workmanship to the detriment of the public, deprive the public of the full benefits of fair competition among prime contractors and subcontractors, and lead to insolvencies, loss of wages to employees, and other evils."[8]
Contrary to Thomason's suggestion there is no inconsistency between the legislative finding and the judicial analyses of statutory purpose described above. The Legislature has found that the public is injured when irresponsible bid practices cause a subcontractor to cut corners in materials or workmanship. Likewise, the public suffers if these practices result in padding the contractor's pockets with larger profits at public expense. Somewhat less directly, the public suffers from added burdens on public services if subcontractors are driven out of business and their employees thrown out of work as a result of such practices. To minimize these evils the Fair Practice Act requires the contractor to identify the subcontractors the public will be paying for, and it makes this identification binding. These requirements rest on a basic principle  that the public is entitled to know exactly what it is paying for when it accepts a contractor's bid, and to get exactly that unless it consents to something different. This is entirely consistent with the idea that the contracting agency has a right to investigate any proposed subcontractor, to reject the prime bid if any subcontractor is unacceptable, and to veto any proposed substitution after the bid is accepted.
It is true that the act has been held to confer a right of action on a named subcontractor who is replaced by another without compliance with the act. (Southern Cal. Acoustics Co. v. C.V. Holder, Inc., supra, 71 Cal.2d 719, 727; Coast Pump Associates v. Stephen Tyler Corp. (1976) 62 Cal. App.3d 421, 423, 426 [133 Cal. Rptr. 88]; Bay Cities Paving & Grading, Inc. v. Hensel Phelps Constr. Co. (1976) 56 Cal. App.3d 361, 366 [128 Cal. Rptr. 632].) Again, however, there is no inconsistency with the public policies just noted. "[T]he purpose of the statute is to protect both the public and subcontractors from the evils of the proscribed unfair bid peddling and bid shopping." (Southern Cal. Acoustics Co., supra, 71 Cal.2d 719, 727, italics added.) A *568 private right of action furthers both purposes. (Bay Cities Paving & Grading, supra, 56 Cal. App.3d 361, 366.) A subcontractor who relies on the act to resist enforcement of a contract is not merely asserting a personal defense conferred by the Legislature and the common law, but is vindicating the public interest in efficient management of public affairs.[9] Therefore, the analogy with the licensing cases fails entirely.
(1b) Even if a setoff could be predicated in some circumstances on a contract violating the Fair Practices Act, we do not believe it could operate as a defense to claims, such as Sherman's, which arise from a wholly separate and unrelated transaction. There is little distinction between permitting a setoff in such a situation and granting an award of damages. Sherman's fortuitous agreement to provide further services to Thomason should not operate to convert void claims into legally cognizable rights. (5) In our view the defense asserted here is analogous in this respect to that of unclean hands, which lies only if the underlying conduct relates directly to the cause of action alleged in the complaint. (Pond v. Insurance Co. of North America (1984) 151 Cal. App.3d 280, 290 [198 Cal. Rptr. 517]; Arthur v. Davis (1981) 126 Cal. App.3d 684, 693-694 [178 Cal. Rptr. 920].)

III. UNJUST ENRICHMENT.[*]
.... .... .... .... ....
The judgment is reversed insofar as it allows a defense of setoff and directs that plaintiff take nothing.[10] In all other respects the judgment is affirmed. The order declaring Sherman the prevailing party and awarding fees is affirmed.
Anderson, P.J., and Poche, J., concurred.
NOTES
[*]   Pursuant to California Rules of Court, rules 976(b) and 976.1, this opinion is certified for publication with the exception of part III.
[1]  For convenience, all sections of the Fair Practices Act are quoted as they appear in the Public Contract Code. They are essentially identical to the like-numbered sections of the Government Code, from which they were transferred in 1986. (See Stats. 1986, ch. 195, § 1.)
[2]  Sherman's president declared that Thomason employees solicited Sherman's involvement and acted to conceal its presence on the job by disguising its equipment and paying its employees through Thomason's payroll accounts. Thomason's president said that he was told otherwise, but Sherman properly objected to this testimony as hearsay. Moreover Sherman's president declared without contradiction that Thomason's president had no personal involvement in the transaction, so that his declaration had no foundation in firsthand knowledge.
[3]  We do not necessarily endorse the procedures described here, particularly the allowance of the setoff defense without its being pleaded in the answer (see Code Civ. Proc., § 431.70) and the summary adjudication of issues not proposed by, and actually adverse to, the moving party (see 6 Witkin, Cal. Procedure (3d ed. 1985) Proceedings Without Trial, § 282, pp. 583-584). Both parties have waived any objection, however, by failing to object at any time up to and including the present appeal.
[4]  Public Contract Code section 4106 provides in part: "If a prime contractor fails to specify a subcontractor ... for the same portion of work to be performed under the contract ... the prime contractor agrees ... that the prime contractor shall perform that portion himself or herself. [¶] If after award of contract, the prime contractor subcontracts ... any such portion of the work, the prime contractor shall be subject to the penalties named in Section 4111."

Public Contract Code section 4107 provides in part: "No prime contractor whose bid is accepted shall ... (c) ... sublet or subcontract any portion of the work in excess of one-half of 1 percent of the prime contractor's total bid as to which his ... original bid did not designate a subcontractor."
[5]  No contractor may bring or maintain an action for his or her services without pleading and proving that he or she was duly licensed to perform them. (Bus. & Prof. Code, § 7031.) Furthermore, it is a misdemeanor to act as a contractor without having a license. (Bus. & Prof. Code, § 7028.)
[6]  "The failure on the part of a contractor to comply with any provision of this chapter does not constitute a defense to the contractor in any action brought against the contractor by a subcontractor." (Pub. Contract Code, § 4112.)
[7]  The Marshall court did not discuss the general rule stated (among other places) in Smith v. Bach, supra, 183 Cal. at page 262: "[W]here a statute prohibits or attaches a penalty to the doing of an act, the act is void, and this, notwithstanding that the statute does not expressly pronounce it so, and it is immaterial whether the thing forbidden is malum in se or merely malum prohibitum." (But see Asdourian v. Araj, supra, 38 Cal.3d at p. 293.)

The Latin terms malum in se and malum prohibitum are attacked by Corbin for concealing the "falsity" of the purported distinction. (6A Corbin on Contracts (1962) § 1378, pp. 24-25.) The First and Second Restatements of Contracts assiduously avoid the terms, focusing instead on legislative intent and the balance of interests between statutory policy and the policy favoring enforcement of contracts. (See Rest., Contracts, § 580, com. a; Rest.2d Contracts, § 178, com. b.)
[8]  "Bid shopping is the use of the low bid already received by the general contractor to pressure other subcontractors into submitting even lower bids. Bid peddling, conversely, is an attempt by a subcontractor to undercut known bids already submitted to the general contractor in order to procure the job." (Southern Cal. Acoustics Co. v. C.V. Holder, Inc. (1969) 71 Cal.2d 719, 726, fn. 7 [79 Cal. Rptr. 319, 456 P.2d 975].)
[9]  We reject the contention that Thomason's conduct was merely a "technical" violation and "not one of the practices that the Act was intended to prevent." Its conduct was expressly forbidden by sections 4106 and 4107 of the act (see fn. 4, ante) and the assertion to the contrary verges on the frivolous.
[*]   See footnote, ante, page 559.
[10]  Since we have concluded that the setoff defense is without merit we need not consider whether defendants were estopped to assert that defense or whether defendant Industrial Indemnity was entitled to rely on it.
