Encapsulation

From TRCCompSci - AQA Computer Science
Revision as of 12:06, 11 June 2018 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Encapsulation is concept of packaging together all of the data items and methods from an object. The data values within an object or class would be separated from the methods. This is done with key words such as "public", "private" and "protected". Data items will normally be private to protect them, and the class or object will have public methods which can access or assign a value to the private data item.This prevents a direct link between the two.

https://www.youtube.com/watch?v=oCEaOJgorWo&index=4&list=PLCiOXwirraUAJPwNTW5gxfJK6Ej18fDP9

Public

The "public" modifier allows data to be viewed and manipulated by any part of the program.

Private

The "private" modifier means that only the class in which data is declared can it be viewed.

Protected

The "protected" modifier means that only the class in which data is declared and its subclasses can see the data.