
586 P.2d 1068 (1978)
99 Idaho 624
SIERRA LIFE INSURANCE COMPANY, an Idaho Corporation, Petitioner,
v.
The Honorable George GRANATA, Jr., District Judge, District Court of the Fifth Judicial District, State of Idaho, In and For the County of Twin Falls, Respondent.
No. 13007.
Supreme Court of Idaho.
November 22, 1978.
*1069 Joseph M. Imhoff, Jr., of Imhoff, Lynch & Davis, Wilbur T. Nelson, of Nelson & Westberg, Boise, for petitioner.
R. Michael Southcombe, Sp. Asst. Atty. Gen., Dept. of Ins., and Max Eiden, Jr., Boise, for respondent.
DURTSCHI, Justice Pro Tem.
In this original proceeding this Court issued an alternative writ of mandate directing the respondent district judge to assume jurisdiction over the subject matter in the case of Sierra Life Insurance Company v. Monroe C. Gollaher, as the Director of Insurance of the State of Idaho, or in the alternative to show cause why he should not do so.
This action involves only a question of law and has been submitted on the basis of the pleadings, briefs, and oral argument.
The pleadings indicate that in February, 1978, Sierra was informed that it would be subjected to a statutory examination by the Idaho Director of Insurance commencing on March 6, 1978. Because of earlier controversies between the Idaho insurance department and Sierra extending over several years, Sierra obtained a conference between the Director and his staff, and the president of Sierra and lawyers representing Sierra. As a result of that conference and subsequent information, Sierra alleges that it had determined that in the course of the proposed examination the Director and his examiners, in determining the admissibility and valuation of certain assets of Sierra, would disregard and fail to properly apply controlling statutes of the state of Idaho; *1070 would also refuse to abide by an earlier administrative decision and order which is legally binding under the principles of res judicata and collateral estoppel; and would refuse to abide by a final order of the District Court of the First Judicial District of the State of New Mexico which is legally binding under the full faith and credit clause of the United States Constitution. Sierra alleges that these claimed actions will result in irreparable damage to Sierra.
Sierra then filed a verified motion with the Director on March 2, 1978, asking the Director to either (1) enter an agreed order regarding the proper conduct of the proposed examination and directing the examiners to comply with the statutes as interpreted by Sierra and give full effect to the prior administrative order and decision and the final order of the New Mexico Court, or (2) stay the proposed examination and afford Sierra a hearing on its alleged grievances.
On March 3, 1978, the Director informed Sierra that he would neither enter the proposed order nor stay the examination. On March 6, 1978, the Director attempted to commence the proposed examination at Sierra's office in Twin Falls County. Sierra then commenced the district court action by filing its original complaint on March 6, 1978. In its complaint Sierra detailed the contentions heretofore summarized and prayed for a declaratory judgment "declaring the rights and legal position of the parties and the law governing the issues." Sierra also sought a temporary restraining order and a preliminary injunction restraining the Director from conducting the examination pending the trial and determination of the declaratory judgment action.
On March 6, 1978, the district court entered a temporary restraining order enjoining the Director and his examiners from commencing any examination of the affairs and conditions of Sierra until further order of the court. On March 16, 1978, the Director filed a motion to dismiss, asserting the following grounds:
(1) The complaint fails to state a claim for relief against this defendant;
(2) Plaintiff's Complaint fails to state a claim for relief cognizable under the Idaho Rules of Civil Procedure for injunction;
(3) Plaintiff herein is not entitled to extraordinary relief through injunction as there exists a clear and adequate remedy at law;
(4) This court lacks jurisdiction over the subject matter and the defendant.
The district judge heard oral argument on the motion and issued his opinion on May 12, 1978, in which he concluded that the district court had jurisdiction to issue the temporary restraining order but did not have jurisdiction over the subject matter as to the declaratory judgment action. The district judge ultimately entered an order of dismissal reciting as grounds that "the District Court of Twin Falls County does not have jurisdiction over the subject matter to hear or consider the declaratory judgment action of the Plaintiff on its merits ...."
This court issued its Alternative Writ of Mandate for the single purpose of considering whether or not the district court had jurisdiction over the subject matter.
As a preliminary matter we note that the extraordinary remedies of mandamus and prohibition are properly used to test questions of jurisdiction. Coeur d'Alene Turf Club, Inc., v. Cogswell, 93 Idaho 324, 461 P.2d 107 (1969); State v. Winstead, 66 Idaho 504, 162 P.2d 894 (1945); Hill v. Morgan, 9 Idaho 718, 76 P. 323 (1904); Peisker v. Chavez, 46 N.M. 159, 123 P.2d 726 (1942).
Furthermore, because of the serious ramifications and consequences which could follow from a court acting without jurisdiction over the subject matter, we recognize that it is important to keep that concept clearly defined. For example, the defense of lack of jurisdiction over the subject matter is never waived (I.R.C.P. 12(h)); purported judgments entered by a court without jurisdiction over the subject matter are void and as such are subject to collateral attack, and are not entitled to recognition *1071 in other states under the full faith and credit clause of the United States Constitution (Restatement of Judgments, § 7 (1942)). In addition, judges who act without jurisdiction over the subject matter may be liable for damages in civil actions. Stump v. Sparkman, 435 U.S. 349, 98 S.Ct. 1099, 55 L.Ed.2d 331 (1978); Bradley v. Fisher, 13 Wall. 335, 20 L.Ed. 646 (1871). For these reasons, it may work considerable mischief to confuse lack of jurisdiction over the subject matter with questions of venue, other aspects of jurisdiction, or defenses which may bar relief or render it improper or inappropriate for a court to proceed with a case even though it has jurisdiction over the subject matter.
Relying on cases from other jurisdictions for support, respondent urges that Sierra failed to exhaust its administrative remedy and that this deprived the district court of jurisdiction over the subject matter.
It is difficult to find truly analogous cases dealing with the defense of failure to exhaust administrative remedies because of (1) the extremely varied nature of the administrative proceedings and remedies involved; (2) the variations in the nature of the judicial relief or remedy sought which brings the judicial and the administrative proceedings into conflict; and (3) the variations in the manner in which the exhaustion doctrine defense is raised procedurally.
Professor Davis suggests the difficulty of looking to the cases for guidance in applying the exhaustion doctrine in these remarks:
The statement the courts so often repeat in their opinions  that judicial relief must be denied until administrative remedies have been exhausted  is seriously at variance with the holdings... .
The law embodied in the holdings clearly is that sometimes exhaustion is required and sometimes not. No court requires exhaustion when exhaustion will involve irreparable injury and when the agency is palpably without jurisdiction; probably every court requires exhaustion when the question presented is one within the agency's specialization and when the administrative remedy is as likely as the judicial remedy to provide the wanted relief. In between these extremes is a vast array of problems on which judicial action is variable and difficult or impossible to predict.
3 K. Davis, Administrative Law Treatise, 56-57 § 20.01 (1958). See McKart v. United States, 395 U.S. 185, 89 S.Ct. 1657, 23 L.Ed.2d 194 (1969). Professor Davis suggests a further area of confusion in the distinction between the doctrines of exhaustion of administrative remedies and primary jurisdiction.
The doctrine of primary jurisdiction, or exclusive primary jurisdiction, or primary decision, or preliminary resort, or prior resort, is not a doctrine that governs judicial review of administrative action. In this important respect, it is altogether different from the doctrines of exhaustion and of ripeness, which govern the timing of judicial review of administrative action. The doctrine of primary jurisdiction determines whether the court or the agency should make the initial decision.
The precise function of the doctrine of primary jurisdiction is to guide a court in determining whether the court should refrain from exercising its jurisdiction until after an administrative agency has determined some question or some aspect of some question arising in the proceeding before the court.
The doctrine of primary jurisdiction does not necessarily allocate power between courts and agencies, for it governs only the question whether court or agency will initially decide a particular issue, not the question whether court or agency will finally decide the issue... . Especially felicitous is the language of a district court that the question is merely one of `priority of jurisdiction.'
3 K. Davis, supra at 1-3 § 19.01. See Grever v. Idaho Telephone Co., 94 Idaho 900, 499 P.2d 1256 (1972).
Because of the variables involved many cases where the defense of the failure to exhaust administrative remedies is involved *1072 do not even require any consideration of jurisdictional concepts.
One situation however, in which a determination as to the relationship of the doctrine of exhaustion of administrative remedies to jurisdictional concepts is required is where the exhaustion doctrine is sought to be enforced through a writ of prohibition. In this situation the courts are sometimes confronted with a semantic dilemma. On the one hand, the writ of prohibition is limited to restraining a lower tribunal from acting without or in excess of its jurisdiction. I.C. § 7-401. On the other hand, in the particular case, the effectiveness of a genuine administrative proceeding involving discretionary decisions by the administrative agency in the field of its expertise or specialization might be destroyed if a violation of the exhaustion doctrine were not promptly stopped even though the lower court which is violating the doctrine has jurisdiction over the person and subject matter within the fundamental meaning of those jurisdictional concepts. In this situation, the more perceptive courts do not abandon or distort the fundamental concepts of jurisdiction over the person and subject matter. They hold either that the exhaustion doctrine involves jurisdiction in its broader aspect and that this is sufficient to invoke relief by way of a writ of prohibition or they invoke the doctrine of primary jurisdiction under their power of administrative supervision. Abelleira v. District Court of Appeal, 17 Cal.2d 280, 109 P.2d 942 (1941); State Racing Comm'n v. McManus, 82 N.M. 108, 476 P.2d 767 (1970). Cf. Idaho Mut. Ben. Ass'n v. Robison, 65 Idaho 793, 154 P.2d 156 (1944) (not involving a writ of prohibition).
Although this court has not faced the issue in the context of a writ of prohibition, we have recognized that the doctrine of exhaustion of administrative remedies can be raised as a defense to a court action in certain situations. However, we have not treated the doctrine as one depriving a court of jurisdiction over the subject matter. V-1 Oil Co. v. County of Bannock, 97 Idaho 807, 554 P.2d 1304 (1976); Franden v. Jonasson, 95 Idaho 792, 520 P.2d 247 (1973); Williams v. State, 95 Idaho 5, 501 P.2d 203 (1972); Grever v. Idaho Telephone Co., supra; Winther v. Village of Weippe, 91 Idaho 798, 430 P.2d 689 (1967); State v. Concrete Processors, Inc., 85 Idaho 277, 379 P.2d 89 (1963); Bohemian Breweries v. Koehler, 80 Idaho 438, 332 P.2d 875 (1958); Idaho Mut. Ben. Ass'n v. Robison, supra.
Because of the great number of variables which must be considered, we do not deem it profitable to engage in a case by case analysis of the cases cited by respondent. Suffice it to say we have noted them and do not find them analogous to the instant case or persuasive.
While the general concept of jurisdiction, as noted, is very broad and has many facets, Abelleira v. District Court of Appeal, supra; Martin v. Soden, 81 Idaho 274, 340 P.2d 848 (1959); Curtis v. Siebrand Bros. Circus & Carnival Co., 68 Idaho 285, 194 P.2d 281 (1948); Peisker v. Chavez, supra; Restatement of Judgments, §§ 4-40 (1942); jurisdiction over the subject matter is a narrow and well-defined aspect of the broader concept.
A classical definition of jurisdiction over the subject matter was adopted by this court in the early case of Richardson v. Ruddy, 15 Idaho 488, 494, 98 P. 842, 844 (1908), as follows:
`Jurisdiction over the subject matter is the right of the court to exercise judicial power over that class of cases; not the particular case before it, but rather the abstract power to try a case of the kind or character of the one pending; and not whether the particular case is one that presents a cause of action, or under the particular facts is triable before the court in which it is pending, because of some inherent facts which exist and may be developed during the trial.'
That basic definition of the concept of subject-matter has been followed and applied in the later cases of White v. Young, 88 Idaho 188, 397 P.2d 756 (1964); Rich v. Williams, 81 Idaho 311, 341 P.2d 432 (1959); Boughton v. Price, 70 Idaho 243, 215 P.2d *1073 286 (1950); Coeur d'Alene Lead Co. v. Kingsbury, 56 Idaho 475, 55 P.2d 1307 (1936) (Ailshie, J., spec. concur.); Sizemore v. Board of County Comm'rs, 36 Idaho 184, 210 P. 137 (1922); Wayne v. Alspach, 20 Idaho 144, 116 P. 1033 (1911).
Boughton approved this pertinent elaboration of the definition:
Such jurisdiction the court acquires by the act of its creation, and possesses inherently by its constitution; and it is not dependent upon the sufficiency of the bill or complaint, the validity of the demand set forth in the complaint, or plaintiff's right to the relief demanded, the regularity of the proceedings, or the correctness of the decision rendered.
70 Idaho at 249, 215 P.2d at 289.
As with the solution of many problems, getting the correct answer depends upon asking the right questions. Boughton also illustrates the type of analysis required to determine whether a court has subject-matter jurisdiction:
In determining our jurisdiction to hear and determine this case, we are not concerned with whether the petition states a good cause of action, with whether the plaintiff is entitled to the relief prayed for, or with whether we have power to render a declaratory judgment in a mandamus proceeding, or at all. We are only concerned with whether the action belongs to that class of cases of which we have original jurisdiction.
70 Idaho at 248-249, 215 P.2d at 288-89.
In answering that critical question the court made two pertinent observations:
An examination of the petition discloses that both in form and essence, these are proceedings in mandamus. The subject matter of the action involves the alleged duty of defendant, Secretary of State, to file plaintiff's declaration of candidacy. Section 7-302, I.C., provides that a writ of mandate may issue `to compel the performance of an act which the law especially enjoins as a duty resulting from an office * * *.'
* * * * * *
Article V, Section 9, of the Idaho Constitution provides that `The Supreme Court shall also have original jurisdiction to issue writs of mandamus....' It thus appears that this court has original jurisdiction to try a case of the kind or character of the one pending.
Id.
Examination of the original and amended complaints in the district court action reveals that the action was in essence and form an action for declaratory judgment and injunction and was not an appeal from an administrative proceeding.
The subject matter of the action involves alleged proposed unlawful action on the part of the Director which allegedly will cause Sierra irreparable harm. Resolution of the issues raised by the complaint requires construction of applicable statutes and determination of the legal effect of a prior administrative decision and order and a prior order of a court of a sister state.
Idaho Code §§ 10-1201, 10-1202, and 10-1205 provide for declaratory judgments as to rights, status and other legal relations under a statute or in any proceeding where a declaratory judgment will terminate a controversy or remove an uncertainty. The claims presented by Sierra in the district court action involve issues which could be appropriately determined in a declaratory judgment action. Idaho Mut. Ben. Ass'n v. Robison, supra. District courts, of course, have jurisdiction to issue injunctions and entertain declaratory judgment actions. Idaho Const. Art. 5, § 20. I.C. § 1-705.
The alternative writ is made permanent and the cause is hereby remanded to the district court with directions to assume jurisdiction for the purpose of considering other defenses presented by the defendant in his motion to dismiss and otherwise take such further action which the court deems appropriate in the exercise of its jurisdiction over the subject matter.
McFADDEN, DONALDSON, BAKES and BISTLINE, JJ., concur.
