If you google these you will probably find actual code snippet of how these are used as well.
André Asantos wrote:But could you give any exemple please?
You'd probably get the answer faster by searching for it yourself. You can always then come back here, post the example, and say "I don't understand something here..."
We generally prefer folks showSomeEffort, rather than just asking for answers to homework problems.
The keyword protected allows access in the same package and in subclasses. Not quite "through inheritance." You have obviously been taught by somebody who thought it means the same as in C++ where (I believe) it does mena "thorugh inheritance."
Justin Fox wrote:Protected is (I believe) used as a keyword for variables that can only be used through inheritance.
Campbell Ritchie wrote:Nor did I.
André Asantos wrote:Hi Masa,
thanks a lot for you attention... But sorry I did not understand your answer...
As the class implements Serializable, and and open Socket is "stateful" the Socket would need to be transient.
Writing to the socket's stream would require synchronization (that there are two methods that write is not relevant). the write and the incriment of "x" needs to be atomic. sync-ing only on the output stream would be best. To implement the Factory pattern, you can't have public constructors so you'd need to make the constructor protected. the subclasses would need to have the static factory methods. as static methods can't be abstract, i had to write in the comments the class needs extending.
anyway. take care.