What is a mechanism of wrapping the data and code acting on the data together as a single unit?

File name : EncapTest.java /
public class EncapTest {
private String name;
private String idNum;
private int age;

public int getAge() {
return age;
}

public String getName() {
return name;
}

public String getIdNum() {
return idNum;
}

public void setAge( int newAge) {
age = newAge;
}

public void setName(String newName) {
name = newName;
}

public void setIdNum( String newId) {
idNum = newId;
}
}

  • Talent
  • Core Java
  • Forum
  • Difference between encapsulation and abstraction?

Please give valid points on how these two OOPs concepts are different from each other

  • Vikrant
  • 12 May
  • 68 Answers

  • Wrapping the data members and member function is called encapsulation. Hiding the data from users is abstraction


  • Encapsulation: Encapsulation means wrapping the data into single unit. Ex: a Java class in which we are writing the data members and member functions Abstraction: Abstraction means bidding the implementation details and only show the functionality Ex: In ATM machine on the screen we only see the functioning and various opeeations to be performed but the implementation details we don't know how the request is send to the server for withdrawal money and so on.


  • Encapsulation is the wrapping of data members and member methods within a class i.e creation of class,class is the depiction of encapsulation. Whereas, Abstraction is hiding the background details from the user that is not necessarily needed for the user to interact with the program ,for e.g a calculator in which user only input and gets the output irrespective of the process going inside.


  • Encapsulation is used for hide the code and data in a single unit to protect the data from the outside the world.Abstraction on the other hand means showing only the necessary details to the intended user.


  • Encapsulation is wrapping up of data ... Abstraction is hiding up of backend data...


  • Encapsulation is like binding up of data or we can say considering the integrated thing as one to avoid complexity whereas the abstraction is hiding of data to make programs user friendly without showing the inner function or complexities.


  • Main difference between them are , encapsulation is the mixing process of code and physical data together and while abstraction is the process of hiding the feeding data from the general users.


  • Abstraction is bascially hiding the implementation and gain access to there functionality by exposing by extend keyword. Encapsulation is bascially binding the data member and method into a single class.We achieved encapsulation by making the datamember as private and using getter and setter.


  • data abstraction is simply hiding the particular data's . encapsulation is a wrapping a all data's in a single file.


  • Encapsulation means binding data and codes together. Class Encapsulate the data and codes inside the class.
    abstraction means hidding irrelevant data from outside users


  • The difference between encapsulation and abstraction is
    encapsulation is wrapping of information 
    the information wrapped in a single unit.
    Abstraction is nothing but a hiding of details or hiding of information .or hiding of background details /information.


  • Encapsulation: It is wrapping up to data and code into single unit.For example, Inner implentation, how keyboard and monitor are collected to each other.
    Abstraction: It is the process to hide details and show only certain features of the object. For example, outer view keyboard and monitor.


  • Encapsulation refers to wrapping up of data and function under a single unit called class and abstraction refers to hinding unnecessary background details.


  • Encapsulation and Abstraction are the two important Object Oriented Programming Concepts.

    Encapsulation - The wrapping up of data and functions into a single unit (i.e. class) is commonly referred to as Encapsulation.
    Example. A human body is a single unit (i.e. class) with multiple systems within it to run properly like nervous system, circulatory system etc.

    Abstraction - The mechanism of representing essential features without including the background details is referred to as abstraction.
    Example. A driver of a car is more interested in driving a car rather than focusing on how the engine is working etc. The examples are real-life examples for simplicity and ease of understanding.


  • 1. Abstraction is generalised term while Encapsulation is subset of Abstraction.
    2.Abstraction solves the problem in design level while Encapsulation solves in implementation level.
    3.Abstraction hides unwanted data and gives relevent data while Encapsulation hides code and data into a single unit to protect from outside world.
    4.Abstraction is Outer layout while Encapsulation is Inner layout.
    5.Abstraction is used in terms of design while Encapsulation used in terms of implementation. 


  • Data Encapsulation: Binding up of data members and member functions together. It provides us Data Hiding,Security. Examples: 1)Cupboard: It is the collection of important documents, clothes, jewellery etc. 2)A capsule: It is wrapped with different medicines. We can achieve data hiding and security by access modifiers. Access Modifiers (Specifiers): Private, Protected, Public. Data Abstraction: A process of hiding non-essential data and showing essential data. Examples: 1) Phone call: When we get the call,we pick up the call,we talk and after that when we finish talking we hang up the phone.But don't want to know internal processes about the phone call. 2) Switchboard : On switchboard,we can see two buttons i.e., ON & OFF.We can press either ON or OFF.But,we don't have to know the internal processing that how wires are connected internally and how the electricity is passing through the wires.


  • 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 on the other hand means showing only the necessary details to the intended user.


  • Encapsulation is wrapping, just hiding properties and methods. Eg: class Abstraction means showing only the necessary details to the intended user.


  • Encapsulation:-

    Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.
    Encapsulation in Java is a mechanism for wrapping the data variables and code acting on the methods together as a single unit. In encapsulation, the variables of a class will be hidden from other classes and can be accessed only through the methods of their current class. Therefore, it is also known as data hiding.

    Abstraction:-

    Abstraction is the quality of dealing with ideas rather than events. 
    In Object-oriented programming, abstraction is a process of hiding the  details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it.


  • Encapsulation:-

    Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.
    Encapsulation in Java is a mechanism for wrapping the data variables and code acting on the methods together as a single unit. In encapsulation, the variables of a class will be hidden from other classes and can be accessed only through the methods of their current class. Therefore, it is also known as data hiding.

    Abstraction:-

    Abstraction is the quality of dealing with ideas rather than events. 
    In Object-oriented programming, abstraction is a process of hiding the  details from the user, only the functionality will be provided to the user. In other words, the user will have the information on what the object does instead of how it does it.
    In Java, abstraction is achieved using Abstract classes and interfaces while encapsulation is implemented using private, package-private and protected access modifier.
     


loadAnswer

  Other Related Discussions

  • Vibez keto Gummies IT SCAM OR 100% CLINICALLY CERTIFIED INGREDIENTS?

  • What is the problem with my Java programme?

  • Enlarge Instagram profile picture

  • While running a program m getting SessionNotCreatedException .

  • Why Learning Ethical Hacking in 2022 is important?

  • What is Software Testing ?

  • Why Choose Software Testing For 2022

  • Why Choose Seven Mentor For Software Testing Classes In Pune ?

  • Why Software Testing Training Is Important?

What is a mechanism of wrapping the data and code acting on the data together as a single unit?

Didn't get the answer.
Contact people of Talent-Core Java directly by clicking here

What is called the wrapping code and data together into a single unit?

Encapsulation is defined as wrapping up of data and information under a single unit.

What is the mechanism of wrapping data and behavior ie variables and methods together as a single object?

Encapsulation in Java is a mechanism to wrap up variables(data) and methods(code) together as a single unit. It is the process of hiding information details and protecting data and behavior of the object. It is one of the four important OOP concepts.

What combines data and methods into a single processing element?

A class combines data and function into a single unit. The method of hiding details of a class is called abstraction.

What is data hiding mechanism?

It is a mechanism used to hide the data implementation details while exposing the data abstraction to the outside world. The process of hiding information behind a well-defined interface is known as encapsulation. Encapsulation is a powerful concept of object-oriented programming.