UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is the difference between abstraction and encapsulation?

Asked by Last Modified  

24 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Experienced Java Professional

Encapsulation is wrapping, just hiding properties and methods. Encapsulation is used for hide the code and data in a single unit to protect the data from the outside the world. Class is the best example of encapsulation. Abstraction refers to showing only the necessary details to the intended user or...
read more
Encapsulation is wrapping, just hiding properties and methods. Encapsulation is used for hide the code and data in a single unit to protect the data from the outside the world. Class is the best example of encapsulation. Abstraction refers to showing only the necessary details to the intended user or hiding the implementation details. read less
Comments

Computer Language Expert

Abstration is Data Hiding and Encapsulation is Binding of the data to To one single unit and that single unit is called object.
Comments

Training Centre

Abstraction allows us to represent complex real world in simplest manner. It is the process of identifying the relevant qualities and behaviors an object should possess; in other words, to represent the necessary feature without representing the background details. Encapsulation is a process of hiding...
read more
Abstraction allows us to represent complex real world in simplest manner. It is the process of identifying the relevant qualities and behaviors an object should possess; in other words, to represent the necessary feature without representing the background details. Encapsulation is a process of hiding all the internal details of an object from the outside real world. The word "encapsulation", is like "enclosing" into a "capsule". It restricts clients from seeing its internal view where the behavior of the abstraction is implemented. read less
Comments

More than 12 years of experience in IT Industry including Science/Computer teaching

Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different to each other. 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...
read more
Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different to each other. 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. Abstraction is the concept of hiding irrelevant details.In other words make complex system simple by hiding the unnecessary detail from the user. Abstraction is implemented in Java using interface and abstract class while Encapsulation is implemented using private, package-private and protected access modifier. read less
Comments

M.Sc. Computer Science and B.Sc. Maths (Hons)

Abstraction refers to hiding details so details are filled while deriving the classes or implementing the abstract methods. The user of the car knows how to drive it not the depth of working of car engine, so car represents an abstract view of its whole machinery. In encapsulation the data remains...
read more
Abstraction refers to hiding details so details are filled while deriving the classes or implementing the abstract methods. The user of the car knows how to drive it not the depth of working of car engine, so car represents an abstract view of its whole machinery. In encapsulation the data remains hidden from external changes directly, as private variables in the class, u cannot access this data outside of the class directly but indirectly through public methods. read less
Comments

16 Yrs of Experience in Teaching

Focusing on the essential features without including background information means u are going to purchase bike that time u are just asking tell me prize color mileage but u never ask is it bike? moving on road or sky? because that information is already there , no need to ask background information and...
read more
Focusing on the essential features without including background information means u are going to purchase bike that time u are just asking tell me prize color mileage but u never ask is it bike? moving on road or sky? because that information is already there , no need to ask background information and encapsulation means wrapping of data and its function into single unit means think student no name age and getRecord printRecord in single class. read less
Comments

Tutor

Encapsulation is data hiding and abstracting is data limiting or shortening the access.
Comments

B.E. (IT)

Encapsulation, at least in the OOP sense, is specifically about hiding implementation and state behind an interface. Abstraction is a more general term. It doesn't necessarily have to hide implementation or state, but it tends to do that. I use abstraction to try to express concepts more clearly, and...
read more
Encapsulation, at least in the OOP sense, is specifically about hiding implementation and state behind an interface. Abstraction is a more general term. It doesn't necessarily have to hide implementation or state, but it tends to do that. I use abstraction to try to express concepts more clearly, and that means putting some implementation, and sometimes state concerns out of view, so I can focus on what I really want to talk about in the code. The purposes are different. To me, abstraction is primarily about expression in code. Encapsulation is a system design strategy. It's about keeping the design details of one entity away from the design thinking that's put into other entities, so that the only means of computation is through interfaces. read less
Comments

Tutor

Encapsulations Encapsulations bind the data with the code that manipulates it and It keeps the data and the code safe. “Mark instance variable as Private ,Mark getters and setter as public” Real Time Example: Every time you log into your email account( GMail, Yahoo, Hotmail or official mail),...
read more
Encapsulations Encapsulations bind the data with the code that manipulates it and It keeps the data and the code safe. “Mark instance variable as Private ,Mark getters and setter as public” Real Time Example: Every time you log into your email account( GMail, Yahoo, Hotmail or official mail), you have a whole lot of processes taking place in the backend, that you have no control over. So your password, would probably be retrieved in an encyrpted form, verified and only then you are given access. You do not have any control, over how the password is verified, and this keeps it safe from misuse. Technical Example: If a data member is private it means it can only be accessed within the same class. No outside class can access private data member (variable) of other class. However if we setup public getter and setter methods to update (for e.g. void setEmpName(String newValue))and read (for e.g. String getEmpName ()) the private data fields then the outside class can access those private data fields via public methods. This way data can only be accessed by public methods thus making the private fields and their implementation hidden for outside classes. That’s why encapsulation is known as data hiding. Let’s see an example to understand this concept better. public class EncapsDemo{ Mark instance variable as Private private String empName; public String getEmpName(){ return empName; Mark getters and setters as public } public void setEmpName(String newValue){ empName = newValue; } } public class EncapsTest{ public static void main(String args[]){ EncapsDemo obj = new EncapsDemo (); obj.setEmpName("John"); System.out.println("Employee Name: " + obj.getEmpName()); } } Output: Employee Name: John • In above example data member (or data fields) is private which cannot be accessed directly. These fields can be accessed via public methods only. Fields empName made hidden data fields using encapsulation technique of OOPs. Abstraction: Abstraction means providing the essential features without showing its inner details or hiding internal implementation. Making a class in abstract is easy. Put the keyword abstract before the class declaration Real Time Example: You want to make a call to your friend. But After dialing ,How the call connected to your friend?(Here internal implementations details will hide) Technical Example: public abstract class Bank { private int accno; private String name; void display_to_clerk () { System.out.println ("Accno = " + accno); System.out.println ("Name = " + name); } void display_to_manager () { System.out.println ("Accno = " + accno); System.out.println ("Name = " + name); System.out.println ("Loan = " + loan); System.out.println ("Balance = " +balance); } } read less
Comments

Senior Software Engineer

Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different to each other. 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...
read more
Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different to each other. 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. Abstraction is the concept of hiding irrelevant details.In other words make complex system simple by hiding the unnecessary detail from the user. Abstraction is implemented in Java using interface and abstract class while Encapsulation is implemented using private, package-private and protected access modifier. Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different to each other. 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. Abstraction is the concept of hiding irrelevant details.In other words make complex system simple by hiding the unnecessary detail from the user. Abstraction is implemented in Java using interface and abstract class while Encapsulation is implemented using private, package-private and protected access modifier. read less
Comments

View 22 more Answers

Related Questions

I have been working in a medical billing company for five years. I want to switch my carrier from non-IT to IT. I have only a BA degree, but I have good knowledge of computers. I know some basics of HTML and manual testing; can I learn java selenium directly to get a job in automation?

Hi Sirajudeen.. Java selenium is one of the good options.. one more easy way to shift to IT is learning Oracle SQL.. Scope of Oracle SQL always stands high since the database is backbone of all developement,...
Sirajudeen
What is the use of the "this" keyword in Java?
'this' refer the current instance of a class. You can get and set data members of current object using 'this' prefix inside there class data type.
Deepak
0 0
9
What are the best books for learning programming languages like C (except let us C), Java, Python, etc.?
you can read "Head First Java",I do read it even now after having 6 years of working experience in Java when I want to refresh some concept. you can also read Core Java, Volume 1 and 2 by Cay S. Horstmann,...
Shashank
0 0
6
how to run a java program
Two ways you can run a Java Program. 1- Through cmd prompt, 2- Through Eclipse. 1- cmd prompt (Write your program and save the file with .java extension. Now open your cmd prompt and give the java file...
Prem Kumar Pathak

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Spring - Dependency Injection (DI)
Spring - Dependency Injection (DI) DI is a framework which provides loose coupling in code. Here loose coupling means no hard coding of the object. Instead of hard coding, we will be injecting these object...

1.1. Reverse an array in Java.
public class Main { public static void main(String args) { int arr = {1, 2, 3, 4, 5}; for (int i = 0; i < arr.length / 2; i++) { int temp = arr; arr = arr; arr = temp; } System.out.println(Arrays.toString(arr)); }}

What Is Applet & Its Life Cycle?
What is Applet & its life cycle?Applet is a Java programme that can be embedded into HTML page.Java Applet runs on the java enables web browsers such as Mozilla & Internet Explorer.Applets are...
I

ICreative Solution

0 0
0


Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

Recommended Articles

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more