Is encapsulation just a capsula creation?Difference between abstraction and encapsulation?Difference between abstraction and encapsulation?Must Dependency Injection come at the expense of Encapsulation?Structuring C++ class hierarchies for maintainability and encapsulationEncapsulation / AbstractionSimple way to understand Encapsulation and AbstractionHow abstraction and encapsulation differ?R: S3 has no encapsulation (and other questions)Is inheritance necessary for encapsulation, abstraction and polymorphism?Private nested classes - are they necessary for composition?Javascript OOP - abstraction (asking for example), encapsulation (grouping together properties/methods or keeping state private?), polymorphism
Why don't we have a weaning party like Avraham did?
Did the CIA blow up a Siberian pipeline in 1982?
Greeting with "Ho"
Too early in the morning to have SODA?
Is the continuity test limit resistance of a multimeter standard?
How long did the SR-71 take to get to cruising altitude?
Where should a runway for a spaceplane be located?
How to remove stain from pavement after having dropped sulfuric acid on it?
"What is the maximum that Player 1 can win?"
What is the highest voltage from the power supply a Raspberry Pi 3 B can handle without getting damaged?
Designing a magic-compatible polearm
Text alignment in tikzpicture
Was the Enigma's double stepping mechanism intentional?
Helping ease my back pain by studying 13 hours everyday , even weekends
Can you use one creature for both convoke and delve for Hogaak?
What is the "ls" directory in my home directory?
How do internally carried IR missiles acquire a lock?
What does it cost to buy a tavern?
Warnings using NDSolve on wave PDE. "Using maximum number of grid points" , "Warning: scaled local spatial error estimate"
How does join() produce different results depending on the arguments?
How to work with PETG? Settings, caveats, etc
Are there any individual aliens that have gained superpowers in the Marvel universe?
Why is "Congress shall have power to enforce this article by appropriate legislation" necessary?
A word for delight at someone else's failure?
Is encapsulation just a capsula creation?
Difference between abstraction and encapsulation?Difference between abstraction and encapsulation?Must Dependency Injection come at the expense of Encapsulation?Structuring C++ class hierarchies for maintainability and encapsulationEncapsulation / AbstractionSimple way to understand Encapsulation and AbstractionHow abstraction and encapsulation differ?R: S3 has no encapsulation (and other questions)Is inheritance necessary for encapsulation, abstraction and polymorphism?Private nested classes - are they necessary for composition?Javascript OOP - abstraction (asking for example), encapsulation (grouping together properties/methods or keeping state private?), polymorphism
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Recently I was talking to a very experienced programmer (8+ years of experience) and he told me that "combining data with functions that work with them in a capsula" is a wrong term for encapsulation. He told me that that was what encapsulation allowed me to do, but not what encapsulation itself was. He told me that as soon as inheritance is not possible without encapsulation, encapsulation must be just a capsula creation (class or anything like that). But today I got interviewed by a less experienced programmer and he was so sure all those classic definitions on wikipedia were right he told me not to even think of passing the interview. So I tried to google all that stuff about encapsulation, and about inheritence not being possible without encapsulation, but didn't find anything. But I can't believe that experienced programmer was wrong, he convienced not only me, but other experienced programmers too. Maybe that correct definition is just something that is lost in the chunks of useless and unimportant info?
So please, give me answers on these two questions:
1) can inheritence be possible without encapsulation? (A class's Inheritence from a class)
2) If not, then can we consider declaring a class encapsulation? Because only after declaring a class we can inherit.
oop encapsulation
|
show 1 more comment
Recently I was talking to a very experienced programmer (8+ years of experience) and he told me that "combining data with functions that work with them in a capsula" is a wrong term for encapsulation. He told me that that was what encapsulation allowed me to do, but not what encapsulation itself was. He told me that as soon as inheritance is not possible without encapsulation, encapsulation must be just a capsula creation (class or anything like that). But today I got interviewed by a less experienced programmer and he was so sure all those classic definitions on wikipedia were right he told me not to even think of passing the interview. So I tried to google all that stuff about encapsulation, and about inheritence not being possible without encapsulation, but didn't find anything. But I can't believe that experienced programmer was wrong, he convienced not only me, but other experienced programmers too. Maybe that correct definition is just something that is lost in the chunks of useless and unimportant info?
So please, give me answers on these two questions:
1) can inheritence be possible without encapsulation? (A class's Inheritence from a class)
2) If not, then can we consider declaring a class encapsulation? Because only after declaring a class we can inherit.
oop encapsulation
Well, the English Wikipedia article mentions two related definitions. Encapsulation in terms of hiding internal variables to the outside world is perfectly possible without inheritance. You might also want to read this.
– MC Emperor
Mar 25 at 7:25
1
I know encapsulation is possible without inheritence. I ask if inheritence is possible without encapsulation
– Марк Павлович
Mar 25 at 7:26
If inheritance in OOP context is the possibility to add methods to an existing class by extending this class, then no encapsulation is involved at all. So yes, it's possible.
– MC Emperor
Mar 25 at 7:34
Of course it is, but it will end up in unmaintainable code very quickly.
– Svetlin Zarev
Mar 25 at 7:37
But encapsulation is not creating a class?
– Марк Павлович
Mar 25 at 7:52
|
show 1 more comment
Recently I was talking to a very experienced programmer (8+ years of experience) and he told me that "combining data with functions that work with them in a capsula" is a wrong term for encapsulation. He told me that that was what encapsulation allowed me to do, but not what encapsulation itself was. He told me that as soon as inheritance is not possible without encapsulation, encapsulation must be just a capsula creation (class or anything like that). But today I got interviewed by a less experienced programmer and he was so sure all those classic definitions on wikipedia were right he told me not to even think of passing the interview. So I tried to google all that stuff about encapsulation, and about inheritence not being possible without encapsulation, but didn't find anything. But I can't believe that experienced programmer was wrong, he convienced not only me, but other experienced programmers too. Maybe that correct definition is just something that is lost in the chunks of useless and unimportant info?
So please, give me answers on these two questions:
1) can inheritence be possible without encapsulation? (A class's Inheritence from a class)
2) If not, then can we consider declaring a class encapsulation? Because only after declaring a class we can inherit.
oop encapsulation
Recently I was talking to a very experienced programmer (8+ years of experience) and he told me that "combining data with functions that work with them in a capsula" is a wrong term for encapsulation. He told me that that was what encapsulation allowed me to do, but not what encapsulation itself was. He told me that as soon as inheritance is not possible without encapsulation, encapsulation must be just a capsula creation (class or anything like that). But today I got interviewed by a less experienced programmer and he was so sure all those classic definitions on wikipedia were right he told me not to even think of passing the interview. So I tried to google all that stuff about encapsulation, and about inheritence not being possible without encapsulation, but didn't find anything. But I can't believe that experienced programmer was wrong, he convienced not only me, but other experienced programmers too. Maybe that correct definition is just something that is lost in the chunks of useless and unimportant info?
So please, give me answers on these two questions:
1) can inheritence be possible without encapsulation? (A class's Inheritence from a class)
2) If not, then can we consider declaring a class encapsulation? Because only after declaring a class we can inherit.
oop encapsulation
oop encapsulation
edited Mar 26 at 7:28
Марк Павлович
asked Mar 25 at 7:00
Марк ПавловичМарк Павлович
7518
7518
Well, the English Wikipedia article mentions two related definitions. Encapsulation in terms of hiding internal variables to the outside world is perfectly possible without inheritance. You might also want to read this.
– MC Emperor
Mar 25 at 7:25
1
I know encapsulation is possible without inheritence. I ask if inheritence is possible without encapsulation
– Марк Павлович
Mar 25 at 7:26
If inheritance in OOP context is the possibility to add methods to an existing class by extending this class, then no encapsulation is involved at all. So yes, it's possible.
– MC Emperor
Mar 25 at 7:34
Of course it is, but it will end up in unmaintainable code very quickly.
– Svetlin Zarev
Mar 25 at 7:37
But encapsulation is not creating a class?
– Марк Павлович
Mar 25 at 7:52
|
show 1 more comment
Well, the English Wikipedia article mentions two related definitions. Encapsulation in terms of hiding internal variables to the outside world is perfectly possible without inheritance. You might also want to read this.
– MC Emperor
Mar 25 at 7:25
1
I know encapsulation is possible without inheritence. I ask if inheritence is possible without encapsulation
– Марк Павлович
Mar 25 at 7:26
If inheritance in OOP context is the possibility to add methods to an existing class by extending this class, then no encapsulation is involved at all. So yes, it's possible.
– MC Emperor
Mar 25 at 7:34
Of course it is, but it will end up in unmaintainable code very quickly.
– Svetlin Zarev
Mar 25 at 7:37
But encapsulation is not creating a class?
– Марк Павлович
Mar 25 at 7:52
Well, the English Wikipedia article mentions two related definitions. Encapsulation in terms of hiding internal variables to the outside world is perfectly possible without inheritance. You might also want to read this.
– MC Emperor
Mar 25 at 7:25
Well, the English Wikipedia article mentions two related definitions. Encapsulation in terms of hiding internal variables to the outside world is perfectly possible without inheritance. You might also want to read this.
– MC Emperor
Mar 25 at 7:25
1
1
I know encapsulation is possible without inheritence. I ask if inheritence is possible without encapsulation
– Марк Павлович
Mar 25 at 7:26
I know encapsulation is possible without inheritence. I ask if inheritence is possible without encapsulation
– Марк Павлович
Mar 25 at 7:26
If inheritance in OOP context is the possibility to add methods to an existing class by extending this class, then no encapsulation is involved at all. So yes, it's possible.
– MC Emperor
Mar 25 at 7:34
If inheritance in OOP context is the possibility to add methods to an existing class by extending this class, then no encapsulation is involved at all. So yes, it's possible.
– MC Emperor
Mar 25 at 7:34
Of course it is, but it will end up in unmaintainable code very quickly.
– Svetlin Zarev
Mar 25 at 7:37
Of course it is, but it will end up in unmaintainable code very quickly.
– Svetlin Zarev
Mar 25 at 7:37
But encapsulation is not creating a class?
– Марк Павлович
Mar 25 at 7:52
But encapsulation is not creating a class?
– Марк Павлович
Mar 25 at 7:52
|
show 1 more comment
1 Answer
1
active
oldest
votes
Well, I'm Sorry, but I fail to see the connection between encapsulation and inheritance.
Encapsulation is hiding your internal implementation behind a publicly visible API.
Basically, it's a separation between a type's actual implementation and what it exposes.
In a broad sense, one can look at even the human body and see encapsulation:
For example: You are breathing air in and out, that's your public API, but the internals of what your body is doing with this air are hidden away inside your respiratory system - your lunges passes oxygen to your blood and collects from it carbon dioxide in return - thus changing the mixture ratio of the gasses in the air you breath, but none of this is visible to the outside world.
Inheritance, in the OOP world, is the ability to take a specific object, and derive an even more specific object from it, while adding capabilities (and sometimes mutating existing capabilities via overriding).
For example: A Dog
is a kind of Mammal
which is a kind of Animal
.
An Animal
might contain methods such as Eat()
and properties such as Weight
and Age
.
A Mammal
might override the Eat()
method to implement suckling (from it's mother's breast) as an infant, but depending on it's age eating solid foods.
A Dog
might introduce another capability such as Bark
.
All of this have nothing to do with encapsulation as desribed in the previous paragraph.
Inheritance is tightly related to another core principle of object oriented programming called Polymorphism - basically, the ability to reference a derived class using it's base class type - perhaps you (or the interviewer) are confusing the two?
However, today is the first time I've seen another definition of encapsulation (and I've been working with oop languages for about two decades now):
A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
Under that
definition, encapsulation is the process of creating capsules - stand-alone code snippets that holds data and ways to interact with it - a.k.a types, classes, etc', and is somewhat related to inheritance - in order to inherit a type, that type first needs to be defined.
However, the way I see it, this definition is not enough to define encapsulation. It can be a part of the definition, but not a stand-alone definition of encapsulation.
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332637%2fis-encapsulation-just-a-capsula-creation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well, I'm Sorry, but I fail to see the connection between encapsulation and inheritance.
Encapsulation is hiding your internal implementation behind a publicly visible API.
Basically, it's a separation between a type's actual implementation and what it exposes.
In a broad sense, one can look at even the human body and see encapsulation:
For example: You are breathing air in and out, that's your public API, but the internals of what your body is doing with this air are hidden away inside your respiratory system - your lunges passes oxygen to your blood and collects from it carbon dioxide in return - thus changing the mixture ratio of the gasses in the air you breath, but none of this is visible to the outside world.
Inheritance, in the OOP world, is the ability to take a specific object, and derive an even more specific object from it, while adding capabilities (and sometimes mutating existing capabilities via overriding).
For example: A Dog
is a kind of Mammal
which is a kind of Animal
.
An Animal
might contain methods such as Eat()
and properties such as Weight
and Age
.
A Mammal
might override the Eat()
method to implement suckling (from it's mother's breast) as an infant, but depending on it's age eating solid foods.
A Dog
might introduce another capability such as Bark
.
All of this have nothing to do with encapsulation as desribed in the previous paragraph.
Inheritance is tightly related to another core principle of object oriented programming called Polymorphism - basically, the ability to reference a derived class using it's base class type - perhaps you (or the interviewer) are confusing the two?
However, today is the first time I've seen another definition of encapsulation (and I've been working with oop languages for about two decades now):
A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
Under that
definition, encapsulation is the process of creating capsules - stand-alone code snippets that holds data and ways to interact with it - a.k.a types, classes, etc', and is somewhat related to inheritance - in order to inherit a type, that type first needs to be defined.
However, the way I see it, this definition is not enough to define encapsulation. It can be a part of the definition, but not a stand-alone definition of encapsulation.
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
add a comment |
Well, I'm Sorry, but I fail to see the connection between encapsulation and inheritance.
Encapsulation is hiding your internal implementation behind a publicly visible API.
Basically, it's a separation between a type's actual implementation and what it exposes.
In a broad sense, one can look at even the human body and see encapsulation:
For example: You are breathing air in and out, that's your public API, but the internals of what your body is doing with this air are hidden away inside your respiratory system - your lunges passes oxygen to your blood and collects from it carbon dioxide in return - thus changing the mixture ratio of the gasses in the air you breath, but none of this is visible to the outside world.
Inheritance, in the OOP world, is the ability to take a specific object, and derive an even more specific object from it, while adding capabilities (and sometimes mutating existing capabilities via overriding).
For example: A Dog
is a kind of Mammal
which is a kind of Animal
.
An Animal
might contain methods such as Eat()
and properties such as Weight
and Age
.
A Mammal
might override the Eat()
method to implement suckling (from it's mother's breast) as an infant, but depending on it's age eating solid foods.
A Dog
might introduce another capability such as Bark
.
All of this have nothing to do with encapsulation as desribed in the previous paragraph.
Inheritance is tightly related to another core principle of object oriented programming called Polymorphism - basically, the ability to reference a derived class using it's base class type - perhaps you (or the interviewer) are confusing the two?
However, today is the first time I've seen another definition of encapsulation (and I've been working with oop languages for about two decades now):
A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
Under that
definition, encapsulation is the process of creating capsules - stand-alone code snippets that holds data and ways to interact with it - a.k.a types, classes, etc', and is somewhat related to inheritance - in order to inherit a type, that type first needs to be defined.
However, the way I see it, this definition is not enough to define encapsulation. It can be a part of the definition, but not a stand-alone definition of encapsulation.
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
add a comment |
Well, I'm Sorry, but I fail to see the connection between encapsulation and inheritance.
Encapsulation is hiding your internal implementation behind a publicly visible API.
Basically, it's a separation between a type's actual implementation and what it exposes.
In a broad sense, one can look at even the human body and see encapsulation:
For example: You are breathing air in and out, that's your public API, but the internals of what your body is doing with this air are hidden away inside your respiratory system - your lunges passes oxygen to your blood and collects from it carbon dioxide in return - thus changing the mixture ratio of the gasses in the air you breath, but none of this is visible to the outside world.
Inheritance, in the OOP world, is the ability to take a specific object, and derive an even more specific object from it, while adding capabilities (and sometimes mutating existing capabilities via overriding).
For example: A Dog
is a kind of Mammal
which is a kind of Animal
.
An Animal
might contain methods such as Eat()
and properties such as Weight
and Age
.
A Mammal
might override the Eat()
method to implement suckling (from it's mother's breast) as an infant, but depending on it's age eating solid foods.
A Dog
might introduce another capability such as Bark
.
All of this have nothing to do with encapsulation as desribed in the previous paragraph.
Inheritance is tightly related to another core principle of object oriented programming called Polymorphism - basically, the ability to reference a derived class using it's base class type - perhaps you (or the interviewer) are confusing the two?
However, today is the first time I've seen another definition of encapsulation (and I've been working with oop languages for about two decades now):
A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
Under that
definition, encapsulation is the process of creating capsules - stand-alone code snippets that holds data and ways to interact with it - a.k.a types, classes, etc', and is somewhat related to inheritance - in order to inherit a type, that type first needs to be defined.
However, the way I see it, this definition is not enough to define encapsulation. It can be a part of the definition, but not a stand-alone definition of encapsulation.
Well, I'm Sorry, but I fail to see the connection between encapsulation and inheritance.
Encapsulation is hiding your internal implementation behind a publicly visible API.
Basically, it's a separation between a type's actual implementation and what it exposes.
In a broad sense, one can look at even the human body and see encapsulation:
For example: You are breathing air in and out, that's your public API, but the internals of what your body is doing with this air are hidden away inside your respiratory system - your lunges passes oxygen to your blood and collects from it carbon dioxide in return - thus changing the mixture ratio of the gasses in the air you breath, but none of this is visible to the outside world.
Inheritance, in the OOP world, is the ability to take a specific object, and derive an even more specific object from it, while adding capabilities (and sometimes mutating existing capabilities via overriding).
For example: A Dog
is a kind of Mammal
which is a kind of Animal
.
An Animal
might contain methods such as Eat()
and properties such as Weight
and Age
.
A Mammal
might override the Eat()
method to implement suckling (from it's mother's breast) as an infant, but depending on it's age eating solid foods.
A Dog
might introduce another capability such as Bark
.
All of this have nothing to do with encapsulation as desribed in the previous paragraph.
Inheritance is tightly related to another core principle of object oriented programming called Polymorphism - basically, the ability to reference a derived class using it's base class type - perhaps you (or the interviewer) are confusing the two?
However, today is the first time I've seen another definition of encapsulation (and I've been working with oop languages for about two decades now):
A language construct that facilitates the bundling of data with the methods (or other functions) operating on that data.
Under that
definition, encapsulation is the process of creating capsules - stand-alone code snippets that holds data and ways to interact with it - a.k.a types, classes, etc', and is somewhat related to inheritance - in order to inherit a type, that type first needs to be defined.
However, the way I see it, this definition is not enough to define encapsulation. It can be a part of the definition, but not a stand-alone definition of encapsulation.
edited Mar 26 at 7:47
answered Mar 26 at 7:20
Zohar PeledZohar Peled
58.9k73577
58.9k73577
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
add a comment |
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
Well we were talking about encapsulation, it would appear I was just horribly mistaught/mistaken. Thanks for you answer.
– Марк Павлович
Mar 26 at 7:25
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
I've added another paragraph to my answer.
– Zohar Peled
Mar 26 at 7:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55332637%2fis-encapsulation-just-a-capsula-creation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Well, the English Wikipedia article mentions two related definitions. Encapsulation in terms of hiding internal variables to the outside world is perfectly possible without inheritance. You might also want to read this.
– MC Emperor
Mar 25 at 7:25
1
I know encapsulation is possible without inheritence. I ask if inheritence is possible without encapsulation
– Марк Павлович
Mar 25 at 7:26
If inheritance in OOP context is the possibility to add methods to an existing class by extending this class, then no encapsulation is involved at all. So yes, it's possible.
– MC Emperor
Mar 25 at 7:34
Of course it is, but it will end up in unmaintainable code very quickly.
– Svetlin Zarev
Mar 25 at 7:37
But encapsulation is not creating a class?
– Марк Павлович
Mar 25 at 7:52