Question: Encapsulation VS Abstraction

Ads

 
 
 

Share on Google+Share on Google+

Rajendra
Encapsulation VS Abstraction
1 Answer(s)      7 years ago
Posted in : Java Beginners
Ads
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

Ads









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
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
getResourceAsStream() vs FileInputStream
getResourceAsStream() vs FileInputStream  getResourceAsStream() vs FileInputStream
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
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
Tutorials   
Java Spring Hibernate Struts Training What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly?

Ads

 
Advertisement null

Ads