63 185
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #15672 in C# for Zulekha

Question #15672


Define a interface ‘Human’ with methods as walk’ and ‘speak’. Define aclass ‘User’ implementing ‘Human’. Define a work() method in User class.Add a class ‘Person’ also implementing Human. Add a method ‘Behave’ inPerson class. In Main method create objects of Person and User andassign them to ‘Human’ type and call Human methods. Can the work andBehave methods be called through Human types? Can we create theinterface objects by calling interface Constructors ? Justify your answer.
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Question15672
{
class Program
{
& static void Main(string[] args)
& {
Human user = new User();
Human person = new Person();

user.speak();
user.walk();

person.speak();
person.walk();

/*
*C#
* Define a interface ‘Human’ with methods as walk’ and ‘speak’.
*& Define aclass ‘User’ implementing ‘Human’. Define a work()
* method in User class.Add a class ‘Person’ also implementing
* Human. Add a method ‘Behave’ inPerson class. In Main method
* create objects of Person and User andassign them to ‘Human’
* type and call Human methods.
* Can the work andBehave methods be called through Human types?
* No, they can't, because these methods are not defined for the
* interface Human, in program we are working with instances
* of User and Person classes as objects of Human type.
*
* Can we create theinterface objects by calling interface Constructors?
* No. The interface is similar to a class, except that none of
* its members is not implemented. The interface includes methods,
* properties, events, and indexers. For it is impossible to
* create an instance of all that it contains, - the signature
* of its members. It's like completely abstract class with out
* any realizations of methods.
*
*&
*/

& }
}
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions