103k views
3 votes
Random Online 1) Using your choice of C# or Java (NOT in Pseudocode), write an interface IMammal. The IMammal contains a method mammalType(). Then write a concrete class Dog that inherits the IMammal interface and includes the unimplemented mammalType() method with at least one PRINT statement, with whatever you like to display. You don’t need to include the main() method.

User Beezer
by
5.2k points

1 Answer

5 votes

Answer:

IMammal:

namespace AnimalInterfaceTest

{

interface IMammal

{

void mammalType();

}

}

Dog Class:

using System;

namespace AnimalInterfaceTest

{

class Dog : IMammal

{

public void mammalType()

{

Console.WriteLine("Mammal type is Dog.");

}

}

}

===============main program=================

using System;

namespace AnimalInterfaceTest

{

class Program

{

static void Main(string[] args)

{

IMammal m1 = new Dog();

Dog dog = new Dog();

m1.mammalType();

dog.mammalType();

Console.ReadLine();

}

}

}

Step-by-step explanation:

User Fissio
by
4.9k points