encapsulation Questions
10
Solved
Suppose I have a method that returns a read-only view into a member list:
class Team {
private List<Player> players = new ArrayList<>();
// ...
public List<Player> getPlayers...
Eberhardt asked 10/7, 2014 at 12:42
41
What is the precise difference between encapsulation and abstraction?
Beachcomber asked 12/4, 2009 at 20:15
20
Solved
Interviewer: What is encapsulation and how do you achieve it in Java?
Me: Encapsulation is a mechanism to hide information from the client. The information may be data or implementation or alg...
Adorn asked 17/8, 2012 at 21:31
5
Solved
I have a struct that has inner mutability.
use std::cell::RefCell;
struct MutableInterior {
hide_me: i32,
vec: Vec<i32>,
}
struct Foo {
//although not used in this particular snippet,
/...
Numbers asked 1/4, 2015 at 22:2
17
Solved
What is the difference between public, private, and protected inheritance in C++?
Proline asked 13/5, 2009 at 20:47
6
Solved
I'm relatively new to Python and struggling to reconcile features of the language with habits I've picked up from my background in C++ and Java.
The latest issue I'm having has to do with encapsu...
Louanneloucks asked 9/4, 2012 at 10:58
15
Solved
I am preparing for an interview and decided to brush up my OOP concepts.
There are hundreds of articles available, but it seems each describes them differently.
Some says
Abstraction is "the pro...
Fondness asked 5/6, 2013 at 11:25
10
Solved
I understand it is a very basic concept in the oops. But still I cannot get my head around. I understood why member variables are private, so class user cannot abuse it by setting up invalid values...
Casuistry asked 12/4, 2010 at 8:28
17
Solved
I try to understand a lot of times but I failed to understand this.
Encapsulation is the technique of making the fields in a class private
and providing access to the fields via public methods....
Algor asked 7/5, 2013 at 12:3
3
Solved
I have some class
class A(object):
def __init__(self, data):
self._data = data
def _equals(self, other):
return self._data == other._data
Pycharm doesn't like that I access other._data becaus...
Brisson asked 4/6, 2019 at 9:6
2
Solved
As per my understanding, these annotations used for methods with an access modifier that allows method invocation from another class for unit testing
@VisibleForTesting - com.google.common.annotati...
Tynes asked 22/4, 2021 at 6:36
27
Solved
I have a project in which we often use Integer.parseInt() to convert a String to an int. When something goes wrong (for example, the String is not a number but the letter a, or whatever) this metho...
Boehike asked 28/9, 2009 at 9:2
6
Solved
What is a good way to apply styling dynamically (i.e. the value of styles are created at runtime) to HTML elements with JavaScript?
I'm looking for a way to package a JavaScript widget (JS, CSS an...
Chantress asked 25/2, 2016 at 14:51
9
Solved
What are the differences between information hiding and encapsulation?
I have read that encapsulation means bundling data and the procedures that should operate on them together. If that is so, doe...
Leyba asked 17/12, 2012 at 11:23
25
Solved
In interviews I have been asked to explain the difference between abstraction and encapsulation. My answer has been along the lines of
Abstraction allows us to represent complex real world in sim...
Aulea asked 30/7, 2014 at 5:34
22
Solved
I had an interview today. I had a question from OOP, about the difference between Encapsulation & Abstraction?
I replied to my knowledge that Encapsulation is basically binding data members &am...
Karolinekaroly asked 2/3, 2013 at 15:52
14
What is encapsulation with simple example in php?
Noh asked 12/6, 2009 at 6:44
16
Solved
How can I use the set and get methods, and why should I use them? Are they really helpful? And also can you give me examples of set and get methods?
Undergird asked 10/7, 2011 at 3:20
5
Solved
Working with data in Python or R, we often load several packages. In some cases, two packages (e.g. foo and bar) might each contain some function (e.g. do_stuff).
The way this is managed in Python...
Villanueva asked 17/7, 2017 at 18:6
9
Solved
Using online dictionary tools doesn't really help. I think the way encapsulate is use in computer science doesn't exactly match its meaning in plain English.
What is the antonym of computer scienc...
Chellean asked 11/11, 2010 at 18:0
3
Solved
I am new to go. I noticed in some libraries there are public methods to a private struct. See for example https://github.com/btcsuite/btcd/blob/master/txscript/stack.go
Does this have a real use c...
Tipperary asked 21/6, 2016 at 18:50
27
Solved
Disclaimer
Yes, I am fully aware that what I am asking about is totally stupid and that anyone who would wish to try such a thing in production code should be fired and/or shot. I'm mainly looking ...
Elocution asked 8/1, 2009 at 12:45
7
Solved
Let's say I have a need for a simple private helper method, and intuitively in the code it would make sense as an extension method. Is there any way to encapsulate that helper to the only class tha...
Misjoinder asked 24/5, 2013 at 16:47
3
What's wrong with this? From objective, and functional standpoints?
import sys
class EncapsulationClass(object):
def __init__(self):
self.privates = ["__dict__", "privates", "protected", "a"]
...
Bunkmate asked 6/10, 2014 at 12:48
8
Solved
Why does this compile:
class FooBase
{
protected:
void fooBase(void);
};
class Foo : public FooBase
{
public:
void foo(Foo& fooBar)
{
fooBar.fooBase();
}
};
but this does not?
class F...
Feudality asked 24/7, 2012 at 13:20
1 Next >
© 2022 - 2025 — McMap. All rights reserved.