objects sharing the same copy of a variable

Asked

Viewed 57 times

0

The goal is to put into practice the contained concepts that I am learning in MALA GUPTA, 2015. So the way I’ve found to contribute is to ask the community to actually implement the concepts. So who is interested and want to contribute and want to demonstrate the knowledge is set the challenge.

So, to put it in context, it’s this: assuming that you need to implement an Abstract Class:

  • Identify when and how to apply abstract classes
  • Build abstract Java classes and subclasses

When I make objects share the same copy of a variable and when I provide them with their own separate individual copy?
And how best to implement in practice, in an application?

Reference:

[MALA GUPTA, 2015], OCP Java SE 7 Programmer II Certification Guide: PREPARE FOR THE 1ZO-804 EXAM

  • 3

    Instead of copying the same text in all questions, wouldn’t it be more interesting to explain what your more specific question is? Reading the questions of the impression of being only a control+c and control+v unbridled, but not a concrete doubt.

  • @diegofm, the goal of copying the introduction is to ensure that no one double-dials the questions and that you stay focused on implementing the answers in practice. Kind of like this my answer even being great I tried to leave well practical.

  • I don’t find this format legal, it seems that the questions do not lead to an objective, which would clarify a concrete doubt or solve a problem. Anyway, the question is yours, this was just a hint. Maybe changing this format to something more direct, the questions gain more visibility and, who knows, good answers.

  • @diegofm, thanks for contributing and for the tip. True! I’m working on another question format. Without too many strings and with more focus. And thanks again! As soon as I finish I will edit the questions with the new format!

  • You want to know when the Subclass should use the variable declared by the Superclass, and when the Subclass should override this variable?

  • @Douglas, actually I would like a more practical answer even if possible implemented. Using OO paradigms is not always trivial and simple, what we usually see in practice implemented in the systems are classes with procedural coding with more than 30 lines, with business rules mixed with infrastructure codes (email, database access, web sevices). So, how do objects from different classes share the same variable? Answer the way you prefer! The important thing is to contribute!

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.