Encapsulation VS Abstraction

Encapsulation VS Abstraction

View Answers

October 14, 2009 at 4:04 PM

Hi Friend,

Encapsulation-Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.

In other words, encapsulation is the ability of an object to be a container (or capsule) for related properties (ie. data variables) and methods (ie. functions).
Ex:
public class Box
{
private int length;
private int width;
private int height;

public void setLength(int p)
{length = p;}

public void setWidth(int p)
{width = p;}

public void setHeight(int p)
{height = p;}

public int displayVolume()
{System.out.println(length*width*height)...
}

public static void main(String args [ ])
{
Box b1=new Box(3,4,5);
b1.displayvolume();
}
Abstraction-The process of abstraction in Java is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object (interface).

Modifiers:
If you want to access a particular variable,method or class from anywhere,then make that variable accessible by using public modifier.

If you want to restrict a particular variable,method or class to be accessible outside the class,use private modifier.

Thanks









Related Tutorials/Questions & Answers:
encapsulation vs abstraction
encapsulation vs abstraction  what is the difference between encapsulation and abstraction
Encapsulation VS Abstraction - Java Beginners
Encapsulation VS Abstraction  Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use specifies like public private.  Hi Friend, Encapsulation-Encapsulation is a process
Advertisements
Encapsulation & Abstraction - Java Interview Questions
Encapsulation & Abstraction  What is the difference between Encapsulation and Abstraction
Encapsulation & Abstraction - Java Interview Questions
Encapsulation & Abstraction  What is the difference between Encapsulation and Abstraction
diff between encapsulation and abstraction code
diff between encapsulation and abstraction code  diff between encapsulation and abstraction code
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output
diff between encapsulation and abstraction code with output   diff between encapsulation and abstraction code with output
Difference between Encapsulation and Abstraction in Java
In this section we will discuss about the difference between Encapsulation and Abstraction in Java. Encapsulation is a process of hiding all the data and methods within a class from outside world. Abstraction on the other hand
encapsulation
encapsulation   how encapsulation is achieved? if i write private variables in my source code, it will achieve encapsulation. this statement is true in all cases
abstraction
abstraction  give a simple example program for abstraction   public class Animal { double energyReserves; boolean isHungry() { return... is an abstraction used in place of an actual animal
abstraction
abstraction  give a simple example program for abstraction  ... is an abstraction used in place of an actual animal.*/   public class Animal...); } } } /*In the above example, the class Animal is an abstraction used in place
Encapsulation in Java
Encapsulation along with Inheritance, Polymorphism, and Abstraction are the four concepts of Object Oriented Programming (OOPs). Encapsulation in Java... and provides access to them by public methods. Encapsulation is a type of data
Encapsulation versus Absraction
Encapsulation versus Absraction  I believe no one in this world knows real difference between Encapsulation and Abstraction , one of them is me as well but if there is anyone who really understand the difference please help me
Abstraction In Java for Java beginners
. Abstraction is one of the 5 fundamentals of OOPS: Abstraction Encapsulation...Abstraction In Java for Java beginners  Hi, As a beginner in Java I am looking for good tutorial that explains the Abstraction concept in Java
Abstraction : Java Glossary
. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts... Abstraction : Java Glossary   ... creation process, programmatically. Here we will discuss Abstraction briefly
Abstraction in flex
Abstraction in flex  Hi... What keyword allows you to implement abstraction better? please tell me about it.... ThanksADS_TO_REPLACE_1   Ans: Flex does not support abstart class directly. ThanksADS_TO_REPLACE_2
Encapsulation in Java
Encapsulation in Java Encapsulation is one of the important feature of object... in to a single unit is called Encapsulation. It means hiding the data and function from the  outside world. Encapsulation can be achieved by making the member
getResourceAsStream() vs FileInputStream
getResourceAsStream() vs FileInputStream  getResourceAsStream() vs FileInputStream
Encapsulation in Java Programming
Encapsulation in Java - One of the 4 OOPs concept In this video tutorial I will explain you the Encapsulation concept of the Java Programming language. Encapsulation is one of the 4 OOPs concepts and other three concepts
ModuleNotFoundError: No module named 'abstraction'
ModuleNotFoundError: No module named 'abstraction'  Hi, My Python... 'abstraction' How to remove the ModuleNotFoundError: No module named 'abstraction' error? Thanks   Hi, In your python environment
Java abstraction - Java Beginners
Java abstraction  Is abstraction and abstract class are related ar same
What is Abstraction In Java?
What is Abstraction In Java?  Hi, What is Abstraction In Java? How to use the Abstraction In Java to write program? Thanks   Hi, Suppose... external access. This process of hiding/securing the class is know as Abstraction
websphere vs weblogic
websphere vs weblogic  websphere vs weblogic Why you are using websphere instead of weblogic
Abstraction In Java
Abstraction In Java In this section we will read about the abstraction in Java. Java is an Object Oriented Programming language and Abstraction is one of the feature of OOPs i.e. Java has the feature of abstraction. In Java abstraction
Reg:Encapsulation - Java Interview Questions
Reg:Encapsulation  where we use encapsulation in programs? how we know that is encapsulated?  Hi Friend, Encapsulation is a process... have to use the encapsulation feature.It hide the details by making the fields
What is Abstraction - Java Beginners
What is Abstraction  What is abstraction in java? How is it used in java..please give an example also  Hi Friend, Abstraction is nothing but data hiding.It involves with the dealing of essential information
Encapsulation in Java 7
Encapsulation in Java 7 This tutorial describe concept of  Encapsulation. It is one of OOPs concept. Encapsulation : Encapsulation is a way of wrapping up data and methods into a single unit. Encapsulation puts the data safe from
oracle vs sql
oracle vs sql  what is the difference between oracle and sql
Abstraction in java - Java Interview Questions
Abstraction in java  Abstraction in java - I know its a very basic question that i can find anywhere else as well... but i am looking for a description as well as an example on Abstraction in java. can anyone
Spring Abstraction with Redis
Spring Abstraction with Redis  Hi.. I have implemented @Cacheable for one method like @Cacheable("parameter1") public String getCompaniesList(String parameter1, String parameter2) throws Exception { //code
ModuleNotFoundError: No module named 'project-abstraction'
ModuleNotFoundError: No module named 'project-abstraction'  Hi, My... named 'project-abstraction' How to remove the ModuleNotFoundError: No module named 'project-abstraction' error? Thanks   Hi
compiler vs interpreter
compiler vs interpreter  "compiled program executes faster especially if the program contains loop" Why
Interface vs abstract class
Interface vs abstract class  Hai, Is there any possible to defining abstract methods in Interface
JETM vs Jprofiler
JETM vs Jprofiler  Can anyone explain the difference between Java Execution Time Measurement(JETM) and Jprofiler
ejb vs hibernate - EJB
ejb vs hibernate  1>>> If we have ejb entity bean why we need hibernate? 2>>> Is hibernate distributed
Java abstraction - Java Beginners
Java abstraction  what is abstraction in java please explain with example  Hi, Abstract Class Abstract classes are those that works only as the parent class or the base class. Subclasses are derived to implement
ejbSelect() vs ejbHome() - EJB
ejbSelect vs ejbHome  Hi, 1) What are the differences between ejbSelect() and ejbHome...() business methods in CMP bean? 2) In Ed Romans Mastering EJB 3rd edition, it is mentioned that ejb finder methods
Derby vs MySQL - SQL
Derby vs MySQL  Hi, I want to know what are the advantages using Derby Database over MySQL.  http://www.roseindia.net/eclipse/plugins/database/index.shtml
inheritence Vs inheritence
inheritence Vs inheritence  what are difference b/w c++ inheritence and java inheritence   Hi Friend, C++ supports Multiple Inheritance while Java does not. Thanks
java vs vb
java vs vb  history of java and advanced products as well as vb? compared with java and vb? finalize list out the table of java and vb products? viewers i want more soon
Abstraction in Java
Abstraction in Java Abstraction is one of the four pillar of OOPS Concept. Abstraction in java is a process by which hiding the irrelevant data  and exposing only the essential feature of object. In java Abstraction
Java Encapsulation Example
Java Encapsulation Example In this section we will read about how to achieve the Encapsulation, feature of OOPs, in Java. Encapsulation is one of the concept of OOPs. Encapsulation is mechanism for hiding informations. This mechanism
Encapsulation
Encapsulation       OOPs revolve around the four concepts: 1. Encapsulation 2. Polymorphism 3. Abstraction 4. Inheritance In OOPs, these concepts are implemented through a class
java vs .net - Java Beginners
java vs .net  which language is powerful now java or .net
portability vs platform independent
portability vs platform independent  sir, pls tell me 1.the differences between platform independent and portability related to java technology 2.how java provides security 3.how can i prove servlet is a single instance
How to make query and abstraction in Java
How to make query and abstraction in Java  Hi, I read the lessons you have in the sites. They are really useful. However, I could not write codes... PostgreSQL database, and I want to make a query and abstraction for a table. Could
Abstraction in Java 7
Abstraction in Java 7 This section elaborate about abstraction. It is one of OOPs concept. Abstraction :  Abstraction means hiding the unnecessary... or object.  In java, you can see concept of abstraction whenever you use
ModuleNotFoundError: No module named 'conan_vs'
ModuleNotFoundError: No module named 'conan_vs'  Hi, My Python... 'conan_vs' How to remove the ModuleNotFoundError: No module named 'conan_vs... to install padas library. You can install conan_vs python with following
ModuleNotFoundError: No module named 'vs-emr'
ModuleNotFoundError: No module named 'vs-emr'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'vs-emr' How to remove the ModuleNotFoundError: No module named 'vs-emr'

Ads