The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
That is a very poor equals method. Please explain why it will give inconsistent and possibly incorrect results.deca leni wrote:
insert this method inside the class
but as I know hash code also must be overide to take effect this.
Do or die...?? No, Do before you die... || (SCJP .6)
Campbell Ritchie wrote:
That is a very poor equals method. Please explain why it will give inconsistent and possibly incorrect results.deca leni wrote:
insert this method inside the class
but as I know hash code also must be overide to take effect this.
Do or die...?? No, Do before you die... || (SCJP .6)
Campbell Ritchie wrote:That is a very poor equals method. Please explain why it will give inconsistent and possibly incorrect results.
Do or die...?? No, Do before you die... || (SCJP .6)
Really? If you tried your equals method like this, you would doubtless get the wrong result. Even after you get it to compile, by putting "o" in the appropriate location. I think you have unbalanced () too.deca leni wrote:public boolean equals(Object o) method is used to check if the tow object are meaningfully equal .so if we check more instant variable equality then we get the exact result.
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
deca leni wrote:what do you mean by serializing. you mean implementing the Serializable interfaces.but as I know, Serialization involves saving the current state of an object to a stream, and restoring an equivalent object from that stream.for an object to be serialized, it must be an instance of a class that implements either the Serializable or Externalizable interface.here we are not going write this object to a file.so we don't want to implements Serializable interface as I think.
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
Why are you quoting Java 1.4.2 documentation?deca leni wrote:String class
Campbell Ritchie wrote:
. . .
and as you know, serialisation and deserialisation produces an object identical to the original. So you can tell what the result of the second printf statement will be . . .
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
Do or die...?? No, Do before you die... || (SCJP .6)
Not convinced. All the methods must be implemented in a concrete class. In an abstract class, you would provide implementations of those methods which are unlikely to change in subclasses. Those which are likely to be different in subclasses should be left abstract. And we have an FAQ or two about abstract classes.Dic pari wrote: . . .
Ans2: . . . If using Abstract class - provide definition for only those your class needs.
. . .
. . . Agreed... I meant to say, if the subclass is going to provide an implementation of the method, leave it abstract in the Parent class (Abstract class).Campbell Ritchie wrote:
Not convinced. All the methods must be implemented in a concrete class. In an abstract class, you would provide implementations of those methods which are unlikely to change in subclasses. Those which are likely to be different in subclasses should be left abstract. And we have an FAQ or two about abstract classes.Dic pari wrote:Ans2: . . . If using Abstract class - provide definition for only those your class needs.
. . .
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|