C# Q&A 8. What is a property? 9. Why do we need to define a property? 10. Can a
ID: 3597857 • Letter: C
Question
C# Q&A
8. What is a property?
9. Why do we need to define a property?
10. Can a class have a property even if the class does not have a private field?
11. Can / should a property be defined as private?
12. Can a method be defined as private ? and if so, when would you do that?
13. What is a static method? And what is the difference between an instance method and a static
method?
14. What is class inheritance?
15. What is the purpose of class inheritance?
16. If a class A inherits a class B, what part of class A does class B inherit?
17. What part of class A that is not inherited from class B
18. If a child class (B) needs to redefine a method in the parent class (A), what should it do? And
what do we call that? (considering simple inheritance)
19. Explain the relationship between a child constructor and its parent constructor.
20. What class is the parent or base class of all the classes in .Net
21. List the methods that each class in .Net automatically inherits.
22. What is the “is a” property? Explain using an example
23. What does polymorphism mean? Explain
24. What keywords must you use to apply polymorphism?
25. Does a child class have to override every method in the parent class?
26. What is an abstract method? Define such method.
27. What is an abstract property? Define such method.
28. What is an abstract class?
29. Can you create an instance of an abstract class? And why?
30. What is the purpose of an abstract class?
31. What is an interface? Elaborate
32. How is a method defined within an interface?
33. How is a property defined in an interface?
Explanation / Answer
Answering first 4 as per chegg policy
8. What is a property?
Property is a member that provide flexible rea/write mechanism or to compute the value of a private field.They can be used as any public data members.
9. Why do we need to define a property?
We need to define property in case we want different representation of field to public access. For example say if we are storing time in seconds for easy computation but user will enter and expect hours to be used, we will provide a property Hourse which will do this conversions implictly
10. Can a class have a property even if the class does not have a private field?
Yes a property can even be defined on a public field.
11. Can / should a property be defined as private?
Yes a property can be defined as private
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.