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

How do I learn Java? From book or internet or a coaching?
According to me....u should start from basic Java..that is core Java... . Find coaching , who teaches Java for beginners.....then later u can go for advance java.
Suresh
0 0
7
Who invented Java language?
James Gosling invented java language
Niranjan
What is the general syllabus covered in core Java training from any institution?
Welcome Course Overview Review of Java Fundamentals The Java Environment Data Types The String Class The StringBuffer Class Arrays Passing Data Types to a Method Constructors &...
Shiv Kohli
0 0
5
Can anyone know if there are tools/apps for representing the objects/classes/methods in the JVM in pictorial way?
rational rose and ibm software architect can be used for design and representation
Raghavendra Reddy
0 0
7
Is Java a compiler or Interpreter?
Java is a programming language and computing platform first released by Sun Microsystems in 1995. A Java compiler is a compiler for the Java programming language. A JVM interprets bytecode and...
Dr Rakesh

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

Ask a Question

Related Lessons

A Tip for the beginners.
The world of programming languages right now is too dense, and too big for any beginner. But at the same time, because of so many options available, it's easier too. You can start with any language that...

Example of DependsOnMethod in TestNG
public class dependsonM { @Test public void login() { System.out.println("login"); } @Test (dependsOnMethods = {"login"}) public void email() { //Intentionally I am failing this testcase Assert.assertTrue(false);...
S

Sarthak C.

0 0
0

How to create a Singleton class?
How to create a Singleton class: Q) What is a singleton class? A) In simple words, a singleton class is a class which can have only one instance at any point of time throughout the application and provides...

CoreJAVA
Core Java Training High Level Course Content Trained by Java Architect 1. Core Java Programming Introduction of Java 2. Data types and Operators 3. Control Flow statements 4. OOPS and its application...
A

Java complete reference-herbert schildt
Sample program: class Sample { public static void main(String args ) { System.out.println("Sample") ; } } Program explanation: Keyword used in line 1- class The name...

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