
84 N.W.2d 179 (1957)
165 Neb. 1
Robert G. GOTTULA, Appellant,
v.
STANDARD RELIANCE INSURANCE COMPANY, Lincoln, Nebraska, et al., Appellees.
No. 34133.
Supreme Court of Nebraska.
July 5, 1957.
*181 Sackett, Brewster & Sackett, Beatrice, for appellant.
McCown & Wullschleger, Robert D. Baumfalk, Beatrice, for appellees.
Heard before SIMMONS, C. J., and CARTER, MESSMORE, YEAGER, CHAPPELL, WENKE, and BOSLAUGH, JJ.
MESSMORE, Justice.
This is an action instituted by Robert G. Gottula under the Uniform Declaratory Judgments Act of the State of Nebraska, in the district court for Gage County against the Standard Reliance Insurance Company, Lincoln, Nebraska, a mutual insurance company merged with the Standard Casualty Company, a corporation, which does not in any manner change the provisions of the policy of insurance here involved nor change the parties defendant, Alvin Behrens, and Ekke Behrens, defendants. The purpose of the action was to have declared the liability of the defendant Standard Reliance Insurance Company, if any, under a policy of insurance issued to the plaintiff Robert G. Gottula. The defendant Standard Reliance Insurance Company filed a special and general demurrer to the plaintiff's petition, demurring specially on the ground that an action for declaratory judgment as prayed for in the plaintiff's petition was not proper where other equally serviceable remedies were provided by law, and demurring generally on the ground that the petition on its face disclosed insufficient facts to constitute a cause of action against the defendant Standard Reliance Insurance Company. The trial court overruled the special demurrer and sustained the general demurrer. The plaintiff failed to amend his petition and elected to stand on it. The trial court dismissed the plaintiff's petition. The plaintiff filed a motion for new trial which was overruled. From the order overruling the motion for new trial, the plaintiff appeals.
We deem it unnecessary to set forth the provisions of the Uniform Declaratory Judgments Act. There is no question but that an insurance contract comes within the purview of section 25-21,150, R.R.S.1943.
This court held in the case of Hawkeye Casualty Co. v. Stoker, 154 Neb. 466, 48 N.W.2d 623, that a contract for insurance and the coverage thereunder was properly determinable under the Uniform Declaratory Judgments Act of this state.
The special demurrer was properly overruled.
In Brunson v. Ranks Army Store, 161 Neb. 519, 73 N.W.2d 803, this court held: "A general demurrer admits all the allegations of fact in the pleading to which it is addressed, which are issuable, relevant, and material, and which are well pleaded; but does not admit the conclusions of the pleader, except when they are supported by, and necessarily result from, the facts stated in the pleading. It does not admit inferences of the pleader from the facts alleged, nor mere expressions of opinion, nor theories of the pleader, as to the effect of the facts, nor allegations of what will happen in the future, nor arguments, nor allegations contrary to the facts of which judicial notice is taken, or which are contrary to law." See, also, Richter v. City of Lincoln, 136 Neb. 289, 285 N.W. 593, and cases cited therein.
In passing on a demurrer to a petition, the court must consider an exhibit attached thereto and made a part thereof, if the allegations stated therein either aid the petition in stating a cause of action or charge facts going to avoid liability on the part of the defendant. Freeman v. Elder, 158 Neb. 364, 63 N.W.2d 327; Kinney Loan *182 & Finance Co. v. Sumner, 159 Neb. 57, 65 N.W.2d 240.
The following are applicable to the case at bar.
The rule is stated in 26 C.J.S. Declaratory Judgments § 141, p. 333: "The use and determination of the demurrer in actions arising under the declaratory judgments act are controlled by the same principles as apply in other cases, and where a demurrer should be sustained in other civil actions, it should be sustained in a declaratory judgment action. Demurrer may be used to test the sufficiency of the complaint if it is vulnerable on any of the statutory grounds of demurrer."
In Dantzler v. Callison, 227 S.C. 317, 88 S.E.2d 64, 67, the court held: "The use and determination of the demurrer in actions arising under Declaratory Judgment Act is controlled by the same principles as apply in other cases."
In the case of Frach v. Schoettler, 46 Wash.2d 281, 280 P.2d 1038, 1044, certiorari denied 350 U.S. 838, 76 S.Ct. 75, 100 L.Ed. 747, the court held: "A proceeding commenced under the declaratory judgment act is subject to the same rules of pleading as any other civil action; hence, in such a proceeding, there is no merit to the contention that a demurrer should not be sustained but that the matter should be heard upon its merits."
In Webb v. Clatsop County School Dist. No. 3, 188 Or. 324, 215 P.2d 368, the court held: "A demurrer may be used to test the sufficiency of a complaint in an action for a declaratory judgment, if complaint is vulnerable upon any of statutory grounds of demurrer." The following cases are cited: Fox v. Title & Trust Co., 129 Or. 530, 277 P. 1003; Central Oregon Irr. Dist. v. Deschutes Co., 168 Or. 493, 124 P.2d 518; Cabell v. City of Cottage Grove, 170 Or. 256, 130 P.2d 1013, 144 A.L.R. 286. See, also, Davis v. State, 183 Md. 385, 37 A.2d 880; Paron v. City of Shakopee, 226 Minn. 222, 32 N.W.2d 603, 2 A.L.R.2d 1227; Meyers v. LaFayette Club, 197 Minn. 241, 266 N.W. 861; Borchard, Declaratory Judgments (2d ed.), pp. 208, 209; 16 Am.Jur., Declaratory Judgments, § 51, p. 323.
Section 25-803, R.R.S.1943, provides for a demurrer as a pleading in this state.
We conclude that a general demurrer may be filed against a petition in a declaratory judgment action such as the instant case.
We examine the petition to ascertain whether the order of the trial court sustaining the general demurrer constituted error as contended for by the plaintiff.
The plaintiff's petition, insofar as deemed necessary to consider here, alleged that on January 12, 1952, the defendant insurance company, for a valuable consideration, issued to the plaintiff its certain combination insurance policy No. AC 922125 on a 1939 model International 2-ton motor truck, model D S35, motor number FAB241-14388, the property of the plaintiff, insuring the plaintiff, among other things, for property damage liability within the limits of $5,000 each accident, from January 12, 1952, to January 12, 1953; and that attached to said policy of insurance was an automobile policy schedule wherein the type of motor vehicle, motor number thereof, and a schedule of coverage and premiums were set forth. Also attached to the said policy of insurance was an endorsement which reads as follows: "Endorsement Attached to and forming part of Policy Number 922125 issued to Robert G. Gottula by STANDARD CASUALTY COMPANYLincoln, Nebraska at its Agency located (city and state) Adams, Nebraska Date of Endorsement January 12, 1952 CORN SHELLER MOUNTED ON TRUCK It is hereby understood and agreed that this policy shall not cover liability arising from operation of the sheller mounted on the insured truck. All other *183 terms and conditions of this policy remain unchanged. Henry Gramann Jr. Agent."
There is also attached to said policy of insurance an automobile endorsement for farm trucks, which reads as follows: "Automobile Endorsement Farm Trucks For attachment to and forming part of Policy No. 922125 of the STANDARD CASUALTY COMPANY, issued to Robert G. Gottula. It is agreed that such insurance as is afforded by the policy for Bodily Injury Liability, for Property Damage Liability and for Medical Payments with respect to the automobile classified as `commercial (farm trucks)' applies subject to the following provisions: 1. The insurance applies to a trailer not described in the policy if designed for use with a private passenger automobile or a farm truck, if not being used with any automobile other than the automobile herein designated or a private passenger automobile, and if not a home, office, store, display or passenger trailer. 2. The insurance also applies with respect to agricultural and other farm implements while being towed by the automobile, provided: (a) the insurance does not apply to the operation of farm machinery; (b) the automobile and such an implement attached thereto shall be held to be one automobile as respects limits of liability. 3. For the purposes of any Use of Other Automobiles provision of the policy, such automobile shall be considered classified as `pleasure and business.' All other terms and conditions remain unchanged. Countersigned January 12, 1952, at Adams, Nebraska By Henry Gramann. Jr. Authorized Agent."
The petition further alleged that true and correct copies of the policy of insurance with the schedule and endorsements thereon were attached to the petition, marked "Exhibit A," and made a part thereof.
The petition further alleged that on or about October 22, 1952, and while and during the time said policy of insurance, schedule, and endorsements thereto attached, remained in full force and effect on plaintiff's truck, the plaintiff drove said truck on which was mounted a corn sheller onto private premises occupied by the defendant Alvin Behrens and owned by the defendant Ekke Behrens, and there parked same and proceeded to shell corn therewith for defendant Alvin Behrens; that the corn sheller mounted on said truck was operated by power furnished by the motor of said truck by means of a power take-off and clutch; that while plaintiff was engaged in the operation of the motor of said truck to furnish power for the corn sheller mounted thereon, a fire started among dry corn husks near or under said truck alleged by defendant Alvin Behrens to have resulted on account of the negligence of plaintiff in operating the motor of his said truck used to operate said corn sheller, with a cracked manifold and the exhaust pipe of said motor disconnected approximately 7 feet behind said motor; that said motor had no muffler; and that plaintiff was aware of the defective and dangerous condition of said motor and was negligent in operating same in the condition in which it was thereby causing the fire complained of by the defendant Alvin Behrens.
The petition further alleged that the defendant Ekke Behrens claims that the plaintiff used the motor on said truck as motive power for the corn sheller mounted thereon; that said motor, at the time plaintiff drove same onto the premises aforesaid, known to plaintiff, had a cracked manifold and an exhaust pipe which was broken off about 3 feet from the motor; that plaintiff negligently caused insufficient water to be carried in the radiator of said truck motor causing same to heat unduly and to emit sparks from said cracked manifold and from said pipe; that notwithstanding plaintiff was aware of the defective and dangerous condition of said motor, he negligently operated same on said premises causing corn husks and buildings to catch fire; and that said defendants Alvin Behrens and Ekke Behrens have each filed petitions and actions against *184 the plaintiff in which they pray for damages.
The petition further alleged that the plaintiff gave the defendant insurance company notice of the Behrens' claims against him as provided for under the terms of the policy; and that the defendant insurance company refused to defend the plaintiff against the claims and actions brought by the Behrens, and advised the plaintiff that he and his truck were not covered under the provisions of the policy of insurance issued to the plaintiff.
The insurance policy also provided: "II Defense, Settlement, Supplementary Payments: As respects the insurance afforded by the other terms of this policy under coverages A and B the company shall: (a) defend any suit against the insured alleging such injury, sickness, disease or destruction and seeking damages on account thereof, even if such suit is groundless, false or fraudulent; but the company may make such investigation, negotiation and settlement of any claim or suit as it deems expedient; * * *."
The plaintiff prayed for a declaratory judgment and decree construing and interpreting the terms of the said policy of insurance, schedule, and the endorsements thereto attached, and prayed that the court find, adjudicate, and decree that the accident thereinbefore described sustained by the plaintiff was within, covered by, and insured against under the provisions of the said policy of insurance.
In Smith v. United States Fidelity & Guaranty Co., 142 Neb. 321, 6 N.W.2d 81, this court pointed out that an insurance policy is a contract. Where there is no uncertainty as to its meaning and the same is legal and not opposed to public policy, an insurance contract will be enforced as it is made. In construing terms used in a policy of insurance, they are to be taken in their plain, ordinary sense. So, also, in construing a written instrument for the purpose of ascertaining the intention of the parties, resort must be had to the instrument as a whole and, if possible, effect must be given to every part thereof. The unquestioned rule is, a writing is interpreted as a whole and all writings forming part of the same transaction are interpreted together. In this connection, it must also be admitted that the parties to a contract of insurance may contract for any lawful coverage. An insurance company has the right to limit its liability and to impose restrictions and conditions upon its contractual obligations not inconsistent with public policy. We have omitted the citations of authority appearing in the above-cited case so as not to unduly lengthen this opinion.
In Pickens v. Maryland Casualty Co., 141 Neb. 105, 2 N.W.2d 593, 594, this court held: "A clause in a public liability policy that the insurer will defend suits for personal injuries brought against the insured although they may be wholly groundless, false or fraudulent are generally construed to obligate the insurer to defend only suits upon claims for which it has assumed liability under the policy." See, also, Brodek v. Indemnity Ins. Co., 292 Ill.App. 363, 11 N.E.2d 228; Lumbermen's Mutual Casualty Co. v. McCarthy, 90 N.H. 320, 8 A.2d 750, 126 A.L.R. 894; United Waste Mfg. Co. v. Maryland Casualty Co., 85 Misc. 539, 148 N.Y.S. 852, affirmed in 169 App.Div. 906, 153 N.Y.S. 1148.
While this rule was announced with reference to a contractor's public liability policy which by its terms did not cover an accident unless it occurred upon the premises owned by or under the control of the insured or on the public highways immediately adjacent thereto, we see no reason why the same rule would not apply to the insurance policy issued to the plaintiff in the instant case.
In Weis v. State Farm Mutual Automobile Ins. Co., 242 Minn. 141, 64 N.W.2d 366, 49 A.L.R.2d 688, this principle is applied to an automobile liability insurance policy where the insurer refused to defend an action against the insured. In the annotation *185 in 49 A.L.R.2d, p. 703, it is said: "The first situation to be discussed is the one where the insurer refuses to defend an action brought against the insured, basing its refusal on the ground that it is under no duty to defend because the claim upon which the action against the insured is founded is not within the coverage of the policy, and it appears that such claim actually is outside the policy coverage. Since in such case the refusal of the insurer to defend does not constitute a breach of contract but, on the contrary, is a justified refusal, the insurer obviously incurs no legal liability by its action. Thus, all the cases agree that where the insurer justifiably refuses to defend, it is not guilty of a breach of contract and no liability attaches to its action." This rule is the majority rule in the United States courts and in the courts of 30 or more states of the Union. Among the cases cited under the annotation are the Nebraska cases of Pickens v. Maryland Casualty Co., supra, and Smith v. United States Fidelity & Guaranty Co., supra.
The annotation continues: "§ 5. Application of rule under policies obligating insurer to defend all suits even though groundless. (a) Generally. Most of the more recent liability policies obligate the insurer to defend all suits brought against the insured even though groundless, false, or fraudulent. Even under such a policy the insurer is still not liable to defend a suit based on a claim outside the coverage of the policy."
In United States Fidelity & Guaranty Co., Baltimore, Md. v. Reinhart & Donovan Co., 10 Cir., 171 F.2d 681, it was stated that an insurer who was not liable under the policy for a claim sued on was not required to defend such suit merely because in the policy the insurer had agreed to defend all suits seeking to enforce such claims even though groundless, the court stating that an insurer is not obligated to defend the groundless suit when it would not be liable under its policy contract for any recovery had therein. See, also, Lunt v. Aetna Life Ins. Co., 261 Mass. 469, 159 N.E. 461. Also cited in the annotation is Pickens v. Maryland Casualty Co., supra.
In the light of the authorities heretofore set forth and considering the plaintiff's petition, we conclude that the insurer in the instant case is under no contractual obligation to defend the action brought against the plaintiff by the defendants Behrens. The trial court did not err in sustaining the defendant's general demurrer.
The judgment of the trial court should be, and is hereby, affirmed.
Affirmed.
