467,869 Members | 1,393 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,869 developers. It's quick & easy.

Few beginner questions,pls help

Hi,
I have few questions and doubts,so please help:

Is it true that Runtime class holds runtime information on all
objects?

Is it true that a subclass has more, or equal amount of functionality
when compared to its superclass?

When i am checking two objects for equality, what are four
characteristics that i must check?

I am not clear about the difference between copying and cloning,is
there any difference at all? if so, is there a risk when cloning?
Jul 17 '05 #1
  • viewed: 1429
Share:
2 Replies

"onTilt" <an**@penet.fi> wrote in message
news:41***************@news.htnet.hr...
Hi,
I have few questions and doubts,so please help:

Is it true that Runtime class holds runtime information on all
objects?

Is it true that a subclass has more, or equal amount of functionality
when compared to its superclass? **** yes - its true *** When i am checking two objects for equality, what are four
characteristics that i must check? ****its up to you - if you're writing the equals(obj) method for that class I am not clear about the difference between copying and cloning,is
there any difference at all? if so, is there a risk when cloning?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.788 / Virus Database: 533 - Release Date: 11/1/2004
Jul 17 '05 #2


--
-P
"Programs that are hard to read are hard to modify.
Programs that have duplicated logic are hard to modify.
Programs with complex conditional logic are hard to modify"

( Kent Beck)
"onTilt" <an**@penet.fi> wrote in message
news:41***************@news.htnet.hr...
| Hi,
| I have few questions and doubts,so please help:
|
| Is it true that Runtime class holds runtime information on all
| objects?
No http://java.sun.com/j2se/1.4.2/docs/api/
|
| Is it true that a subclass has more, or equal amount of functionality
| when compared to its superclass?
Yes
|
| When i am checking two objects for equality, what are four
| characteristics that i must check?
http://www-106.ibm.com/developerwork...-jtp05273.html
|
| I am not clear about the difference between copying and cloning,is
| there any difference at all? if so, is there a risk when cloning?
Yes there is a huge difference.
Imagine you have an object A which contains a reference to object B,
if you copy object A to object C, then you have a new object - object C, but
object C still has a reference to object B. This may not be what you
require.
Now imagine that you override object A's clone method & in this method you
set it's reference to object B to a new object of the same type as B & copy
B's data into it. Now you clone object A to object C, then C no longer has a
reference to object B, but to a new object with the same data which was in
object B.
The difference here is that if the copied object C modifies object B this is
the SAME object B that object A points to, so both object A & C now have the
same modified data in object B.
With the cloned object C, if it modifies its NEW referenced object of the
same type as B, then it has no effect on object B (as it is modifying the
new Object created in its clone() method), so the objects (which are of the
same type as B) referenced from A & C now contain different data.

In the future try posting to comp.lang.java.help, it is a much higher
traffic group than this one :-)

--
-P
"Programs that are hard to read are hard to modify.
Programs that have duplicated logic are hard to modify.
Programs with complex conditional logic are hard to modify"

( Kent Beck)
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Rensjuh | last post: by
15 posts views Thread by Pelle Beckman | last post: by
14 posts views Thread by z_learning_tester | last post: by
3 posts views Thread by Kapil Patry | last post: by
27 posts views Thread by MHoffman | last post: by
3 posts views Thread by ericwan78 | last post: by
1 post views Thread by Robert J. Bonn | last post: by
10 posts views Thread by See_Red_Run | last post: by
22 posts views Thread by ddg_linux | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.