# Can a data abstraction use a class as a field, parameter, or return type?

I think that everyone will agree that the following class achieves data abstraction (hiding of its internal representation):

class A {
private List x = new ArrayList();

public List getX() {
return this.x;
}

public void setX(List x) {
this.x = x;
}
}


But could we say the same about the following one, which uses a class (instead of an interface like in the previous class) as a field type, parameter type, and return type?

class B {
private ArrayList x = new ArrayList();

public ArrayList getX() {
return this.x;
}

public void setX(ArrayList x) {
this.x = x;
}
}

• – D.W.
Jul 6, 2021 at 3:55
• Personally i wouldn't even consider the first one as data abstraction Jul 6, 2021 at 4:39
• You have tagged your question with both abstract-data-types and object-oriented. That is somewhat confusing because ADT-based data abstraction and object-oriented data abstraction are very different, and in some sense even opposites. You should be clear about which one of the two you mean. See for example On Understanding Data Abstraction, Revisited by William R. Cook for a simple explanation. Jul 6, 2021 at 6:44
• @JörgWMittag I am currently reading Luca Cardelli’s paper On understanding types, data abstraction, and polymorphism, which prompted William Cook to write his paper on the subtle distinction between abstract data types and objects. Since I have not started reading William Cook’s paper, I did not want to exclude any possibilities, especially because I feel that the answer is precisely about this distinction. Could you write an answer? Jul 6, 2021 at 7:22
• To be honest, the example might be too simplistic. Especially since OO is all about behavior, and OO-abstraction is behavioral abstraction, but there is no behavior in your example. Jul 6, 2021 at 8:22