Encapsulation - Research Paper Example

Comments (0) Cite this document
Encapsulation Object-oriented programming has four key concepts: abstraction, encapsulation, inheritance and polymorphism. Encapsulation is the technique used by a programmer to control the extent to which classes hides their implementation details and internal data from other classes…
Download full paperFile format: .doc, available for editing
GRAB THE BEST PAPER97.6% of users find it useful
Encapsulation Research Paper
Read TextPreview

Extract of sample "Encapsulation"

Encapsulation Object-oriented programming has four key concepts: ion, encapsulation, inheritance and polymorphism. Encapsulation is the technique used by a programmer to control the extent to which classes hides their implementation details and internal data from other classes. Hiding implementation details allows programmers to rework the implementation details of say a method within a class without changing the code that calls the altered method (Sierra & Bates, 2008). This way, encapsulation protects the data and code of one module from being randomly accessed by other modules. For this reason, information hiding and/or data hiding are terms that are often used to denote encapsulation. Communication between modules therefore can only take place through public programming interfaces, which in this case will be that particular code’s APIs (Application Programming Interfaces). The main reason why encapsulation is key concept of object-oriented programming is that it gives code increased / better maintainability, flexibility and extensibility. This is of critical importance in the development of code libraries. The designers of Java libraries or libraries for any other programming languages want their code to behave the same wherever they are used universally. They would also like to have the freedom to optimize their code without affecting the correctness of other any other code using them. Encapsulation gives programmers the freedom to make changes and improvements to their modules with the certainty that the client code will not be affected by those changes (Eckel, 2003). The most popular facility used for encapsulation in Java is use of access control mechanism which specifies the accessibility of members, interfaces and classes. The accessibility of a member, interface or class is determined in two ways. The first way is the default or package access which comes inherently from the location of where the declaration of a member is done. The second way is the use of any of the following three access modifiers on the declaration statement: public, protected and private (Bloch, 2008). The levels of access control in increasing accessibility is as follows: private access, package or default access (which has no keyword), protected access and public access. Package access applies to any class, member or interface that is declared without specifying an access modifier. Non-nested or top-level classes and interfaces can only use either public access or package / default access modifiers. Instance variables, methods, nested interfaces and nested classes could use any of the following access levels: (1) public access, where the member is accessible from anywhere; (2) protected access, where – subject to a few restrictions - members are accessible from subclasses of the class where they have been declared and from any class in the package they have been declared in; (3) package / default access, where the member is accessible from classes within that package; and (4) private access where the member can only be accessed from within the top-level class it is declared (Bloch, 2008; Eck, 2011; Sierra & Bates, 2005). The example below shows the concept of encapsulation of data by use of access specifiers and accessor methods. class Student { private int age; private String registrationNo; public void setAge(int newAge){ this.age = newAge; } public int getAge(){ return age; } public void setRegistrationNo(int regNo){ this. registrationNo = regNo; } public String getRegistrationNo(){ return registrationNo; } }// end Student Suppose another class, say, Teacher wants to access the instance variables age and registrationNo, in the example above it will not be able to do so directly because they are marked private. To access these member variables, class Teacher will have to use the accessor methods setAge(), getAge(), setRegistrationNo(), and getRegistrationNo(). In this case the accessor methods could be described as class Student’s API. Java differs with other programming languages when it comes to encapsulation on two fronts. Firstly, Java has three access specifiers (private, protected and public) whereas other languages such as C# have five (private, internal, protected internal, protected and public). Most importantly though is that in Java, the rule of thumb is to ensure that members or classes are made as inaccessible / private as possible and to expose only those methods that you want the client programmer to use (Bloch, 2008; Eckel, 2003). In other languages such as C, the rule of thumb is to keep entities as accessible as possible without restriction. References Bloch, J. (2008). Effective Java (2nd ed.). Upper Saddle River, NJ: Addison-Wesley. Eck, D. J. (2011). Introduction to Programming Using Java, Version 6.0. Retrieved from Eckel, B. (2003). Thinking in Java (4th ed.). New York: Prentice Hall. Sierra, K., & Bates, B. (2005). Head First Java (2nd ed.). Sebastopol, CA: O’Reilly Media, Inc. Sierra, K., & Bates, B. (2008). SCJP Sun Certified Programmer for Java 6 Study Guide Exam (310-065). New York: McGraw-Hill.  Read More
Cite this document
  • APA
  • MLA
(“Encapsulation Research Paper Example | Topics and Well Written Essays - 750 words”, n.d.)
Encapsulation Research Paper Example | Topics and Well Written Essays - 750 words. Retrieved from
(Encapsulation Research Paper Example | Topics and Well Written Essays - 750 Words)
Encapsulation Research Paper Example | Topics and Well Written Essays - 750 Words.
“Encapsulation Research Paper Example | Topics and Well Written Essays - 750 Words”, n.d.
  • Cited: 0 times
Comments (0)
Click to create a comment or rate a document

CHECK THESE SAMPLES OF Encapsulation Research Paper

Database Structures, Languages, and Architectures

.... Different tables are related to each other on the basis of some common attribute and n-ary relations are maintained between the tables. The information in the tables is independent of any changes that might be made within some rows and columns i.e. they can be rearranged at any time. Relational database models facilitate the creation of consistent and logical representation of data. 3. Object Oriented DBMS An object oriented database management system (OODBMS) is defined as the database that is based on object oriented concepts. There are four important concepts of object oriented designs namely, inheritance, data encapsulation, object identity and polymorphism. Data is represented in the form of objects in an OODBMS....
3 Pages(750 words)Research Paper

Art in the Renaissance Period

...? Art in the Renaissance Period Year Level – Section Academic December 19, Art in the Renaissance Period Introduction As the periodthat revived the society’s appreciation of the classical arts, the Renaissance strove to resurrect and emulate the art of the ancient Greeks and Romans through the emphasis on humanism. Thus, Renaissance art elevated the understanding of the essence of man from being a creature of God to being the center of the universe. As such, all forms of art during the Renaissance sought to attain one thing—the encapsulation and expression of human beauty. In this paper, I aim to clearly and succinctly discuss the unique characteristics of Renaissance art by highlighting on three aspects: firstly, the...
4 Pages(1000 words)Research Paper

Reflections on Learning Related to Information Systems

...responsive to changes undertaken and the changes may be implemented to the individual objects which do not call for a system overhaul. Through encapsulation there is simplicity and effectiveness in object interaction and communication thus testing, debugging and system maintenance is simplified. Easier to manage because of the fact that code can be reused and also because the functionality is modeled using objects and classes. It is possible to use code which has been written before. There is code re-use. With object oriented programming, there is a lot of flexibility because it is possible to get code which performs the same function for a given functionality. Computer science is a field in science hich deals with...
3 Pages(750 words)Research Paper

Object Oriented Programming as child classes or derived classes. This illustrates that the patent and child classes are related within a structure which leads to a hierarchy. Encapsulation is a concept and principle in object oriented programming in which the designer of a program hides the manner in which an object behaves from the approach of implementation. Encapsulation also includes separation of the looks of an object or it appearance from the methods through which its behavior is implemented. Encapsulation emanates from the fact that objects within a program have well defined interfaces (Ramsin and Richard 31). These are the publicly accessible methods and fields. Therefore when information about objects...
7 Pages(1750 words)Research Paper

Design Patterns - Behavioral, Creational, Structural

...designs, including memento for behavioral patterns, singleton for creational patterns and lastly facade for structural patterns. Memento Pattern This is a software design pattern that has the capability of bringing back an object to its initial state. As a pattern, it allows the initial state of an object to be restored without interfering with the rules of encapsulation. This means that the arising object can be designed appropriately, though it can be restored to its original state. Therefore, memento pattern has the ability of restoring the internal state of an object without breaking the encapsulation rules. As a behavioral pattern, Memento indicates the manner through which communication between...
3 Pages(750 words)Research Paper

Insider threat and Physical vulnerability

... and Encapsulation. Retrieved From: Shaw, E., Ruby, K. G. & Post, J. M. (2013). Political Psychology Associates. Retrieved From: Trend Micro (2013). Data Protection- Data Security Management. Retrieved From: Insider Threat and Physical Vulnerability Insider Threat and Physical Vulnerability Introduction The health care industry can beseen to be adopting more of technological advancements in their operations with each day passing. While this can be seen as a great step towards the provision of better health care services, the idea has faced some...
4 Pages(1000 words)Research Paper


...Question 29 a) Dynamic data structures can grow or shrink according to the wish of the programmer. Static values do not hold this property; once declared they remain fixed to the defined length. b) After the assignment chPtr = new char[10]; chPtr content will be the memory location where char[10] is stored. Question 30 a) Encapsulation in object oriented programming is a technique that integrates data and operations to make an object. The benefits of encapsulation are abstraction and security. Abstraction in the sense that the operations and properties of an object are hidden from the outside world who is not bogged down with the inner workings of the object and security because the outside world can...
9 Pages(2250 words)Research Paper

Research paper on object oriented programming as a modular approach. As compared to this, in an object oriented approach, related data and functions are grouped together in order to create objects. Data items are termed as attributes and functions are termed as behaviors in an object oriented paradigm. Their encapsulation through a mechanism furnishes a blue print for an object which is referred to as a ‘class’. It is like a script of a movie or a recipe of a dish. CORE CONCEPT An object Oriented approach towards the creation of a program is based upon the identification of objects at first. The three main principles that lie at the core of Object Oriented Programming are encapsulation, inheritance and polymorphism. An object is a separate...
1 Pages(250 words)Research Paper

Hazardous materials

...and encapsulation. In developed countries, the use of microwave radiation, sanitary landfills and wet thermal treatment methods are applied. Incineration is applied in pathological waste, infectious material and sharps. This method is effective as it destroys about 99% of the micro-organism found in the hazardous material (WHO, 1999). It is also has low investment and operation costs. Safe burying of hazardous waste involves the burying of waste in a pit whose access is limited. The pit is covered with clay so as to extend the useful life of the pit to be used for hazardous materials. Each time materials are disposed the waste layer is covered with a thick layer of clay soil. This method has been successfully used for...
10 Pages(2500 words)Research Paper

Network Virtualization in Cloud

...Cloud computing is originally based on the sole concept of virtualization. Making use of the virtually allocated memory presented as physical memory.There are number of featuring elements and requirements within that must be taken into account. These include elements such as encapsulation, partitioning of the memory into physical and virtual portions and allocating remote I.P addresses. Creating an abstract layer concept that hides the overall original identity and increases the options of sharing and using more data make up for the features and objectives behind the cloud computing concept. The physical servers that are originally installed at the back end are incorporated for the purpose of providing original data and reference... computing ...
3 Pages(750 words)Research Paper
sponsored ads
We use cookies to create the best experience for you. Keep on browsing if you are OK with that, or find out how to manage cookies.

Let us find you another Research Paper on topic Encapsulation Research Paper for FREE!

Contact Us