Accessing private instance variables of parent from child class?

No, not according to the java language specification, 3rd edition: 6.6.8 Example: private Fields, Methods, and Constructors A private class member or constructor is accessible only within the body of the top level class (ยง7.6) that encloses the declaration of the member or constructor. It is not inherited by subclasses. But regardless of this language … Read more

Final interface in Java?

Interfaces are 100% abstract and the only way to create an instance of an interface is to instantiate a class that implements it. Allowing interfaces to be final is completely pointless. EDIT The questions is not as outright outrageous as I first thought. A final interface is one that cannot be extended by other interfaces … Read more

Private methods in Python

Python doesn’t have the concept of private methods or attributes. It’s all about how you implement your class. But you can use pseudo-private variables (name mangling); any variable preceded by __(two underscores) becomes a pseudo-private variable. From the documentation: Since there is a valid use-case for class-private members (namely to avoid name clashes of names … Read more

Is C++ an Object Oriented language?

C++ is usually considered a “multi-paradigm” language. That is, you can use it for object-oriented, procedural, and even functional programming. Those who would deny that C++ is OO generally have beef with the fact that the primitive types are not objects themselves. By this standard, Java would also not be considered OO. It is certainly … Read more

python subclassing multiprocessing.Process

Subclassing multiprocessing.Process: However I cannot get back the values, how can I use queues in this way? Process needs a Queue() to receive the results… An example of how to subclass multiprocessing.Process follows… from multiprocessing import Process, Queue class Processor(Process): def __init__(self, queue, idx, **kwargs): super(Processor, self).__init__() self.queue = queue self.idx = idx self.kwargs = … Read more

Should internal class methods return values or just modify instance variables?

Returning a value is preferable as it allows you to keep all the attribute modifying in one place (__init__). Also, this makes it easier to extend the code later; suppose you want to override _build_query in a subclass, then the overriding method can just return a value, without needing to know which attribute to set. … Read more