Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Encapsulation VS Abstraction
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rajendra
Encapsulation VS Abstraction
1 Answer(s)      5 years and 3 months ago
Posted in : Java Beginners



Advertisement
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.... Thanks   Ans: Flex does not support abstart class directly. Thanks
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
Java abstraction - Java Beginners
Java abstraction  Is abstraction and abstract class are related ar same
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
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
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
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
websphere vs weblogic
websphere vs weblogic  websphere vs weblogic Why you are using websphere instead of weblogic
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
oracle vs sql
oracle vs sql  what is the difference between oracle and sql
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
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
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
Advertisements
 

 

 

DMCA.com