Home | | C Sharp and .NET Framework(CNF) | Review OOP Concept

Chapter: C# and .NET Framework

Review OOP Concept

Class - > is like the BLUEPRINT to make something. Object - > is made from a BLUEPRINT. So you can make many Objects from 1 Class.

Review OOP Concept


Class - >  is like the BLUEPRINT to make something.

 Object  - >  is made from a BLUEPRINT. So you can make many Objects from 1 Class.

When you make an OBJECT from a CLASS, it is called an INSTANCE of a Class.

 

Objects have

1.       Name  - >  like a name you give an object  - >  Identifier

2.       Attributes  - >  like specific characteristics for the object  - > Variables

3.       Behaviours  - >  like actions the object can perform  - >  Instance Methods

 

UML – Unified Modeling Language

 

Because in Java everything is wrapped in a class, it can get very confusing! We can use UML to show the structure of a Class.

 

Name of Class

±        Attributes/Variables : Data-Type

±        Behaviour/Methods (param name: param data-type, etc …): Return-Type

 

 

±        - >  plus or minus represent the ACCESS MODIFIERS, which are:

+ - >  public -  - >  private

Example



 


Encapsulation and Access Modifiers

We  use  public and  private to  add  security to  VARIABLES  and  METHODS.  This  is  called ENCAPSULATION.

 

public - > means a VARIABLE or METHOD can be used INSIDE & OUTSIDE the class

private - > means a VARIABLE or METHOD can only be used INSIDE the class

 



 

Why are the variables private and methods public?

Because we want to protect variables from being accessed directly; so they can’t be changed or used incorrectly. To GET a value from a variable or to GIVE a variable a value we write public methods to do this.

 

For example we could have changed the setMarks method from the Student Class to prevent users from entering an incorrect value:

 


 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
C# and .NET Framework : Review OOP Concept |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.