Answer to Question #171697 in C# for satwi

Question #171697

Write a class C2 that inherits all the functionality of A2 and B2,

// with the same stipulation that it should take f() from A2 and g() from B2.


1
Expert's answer
2021-03-15T12:22:49-0400
//Write a class C2 that inherits all the functionality of A2 and B2,
// with the same stipulation that it should take f() from A2 and g() from B2.

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            C2 c2 = new C2();
            c2.f();
            c2.g();
        }
    }

    public class A2
    {
        public void f()
        {
            Console.WriteLine("Call f() from class A2");
        }
    }

    public class B2 : A2
    {
        public void g()
        {
            Console.WriteLine("Call g() from class B2");
        }
    }

    public class C2 : B2
    {
        public C2()
        {
            Console.WriteLine("Create class C2");
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS