Encapsulation definition with example
which is nothing but wrapping up of code and data. Here code is function and data is attributes. This approach will reduce the relationship between the objects as well give access to maintainability of the code.Below table show how can we able to connectivity to the other objects.
This is one of the good OOPS DOTNET Interview Question.
Access Modifier | Description (access information) |
---|---|
private | Only for with in the same type. These are default for all types (int, string,...) |
protected | If we use inheritence only derived types call access of base type |
internal | we can accesses with in the assembly. |
protected internal | this is combination of protected and internal. |
public | we can access any where. |
Example:
using System; class BankAccountDetails { private string m_CustName; public string bankCustName { get { return m_CustName ; } set { m_CustName = value; } } }
In this example. we are hiding the string bankCustName to the other object.
See more OOPS DOTNET Interview Questions
See more ASP.NET, C#.NET, SQL Server and more Interview Questions
Post a Comment
Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.