Luciano Leite

Greenhorn
+ Follow
since Mar 01, 2006
Luciano likes ...
jQuery Oracle Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Luciano Leite

Yes, the question is false because you can compare any class you want (everybody extends Object).
In real life is not a good idea....and guess what? sometimes it IS necessary, because the model(legacy made by other people) needs so. And the happy path lays on implementing(overrinding Object version) Equals and HashCode methods properly...may the force be with you!!!
Hi,
Maybe you can compare two different classes that one extends another
or both of them implements a commom interface.
Hi, Naseem!!!

Point = Avoid as many problems in run-time as possible. i.e. the compiler check every method invocation... why? to certificate that method(with that arguments) exists... so ... the code works!!

What is the point in declare that a class implements Serializable if it contains references variables to classes that doesn't implements too?

"Maybe you can serialize.... maybe not!! Good Luck!!" ???

17 years ago
That's my point... why don't the compiler force it?? Why it let you compile you class and take the risc of fall in runtime?

They invented Generics.... why don't fix it too? Why it is not a checked exception? Or at least generate an warning?

There must be a reason... but I did not find it... yet!!
17 years ago
class A implements Serializable {}

class B implements Serializable {
A ref = new A();
}

How could you make ref to "point" to a object that doesn't implements Serializable?
17 years ago
Ok... just for fun!!

A reference variable of a class that implements Serializable... could point to an object that doesn't implements?

17 years ago

Originally posted by Ulf Dittmer:
Serializable is an interface. All the compiler does is to check that the class implements all methods declared in that interface. Since there are none, every class passes this test.

Using Serializable is more like a promise by you -the author of the class- that the class is actually serializable, i.e. that it doesn't contain references to objects that can't be serialized.




Thanks for reply!!

A class passes on test only if it(or one of its superclasses) implements the interface, right?

I think that the compiler should ensure that... "if you implements Serializable you can't declare references to other class that doesn't implement it too"

Why not?

[]'s
17 years ago
Hi all!!!

Does anyone know why javac lets you compile a class that implements Serializable and has references variables to other objects that doesn't implements that interface?
(If you try do serialize an instance of this class you may fall in runtime)
I think it should be a checked exception!!
There must be a reason, of course... but I did not find it!!

Thanks in advance
17 years ago
Hi, Sergio!!

I think you should donwload the exam objectives and search on Ranch, topic by topic, then you'll can see what you must to know.

Abra�o
Hi all!!

Maybe old

...but why use



instead just?



What is the utility of String.intern() method if Strings without "new" are pooled by default?

Thanks
Tks John, don't worry... your explanation was perfect "32bits... left 23"
Hi!

System.out.println(x); // at line 8 Prints 123456792 (nearest int divisible by 8)

For intNumber = 123456792, 1234567800, 1234567808... line 8 prints 0 and line 9 true

at line 7 floatNumber is round... why? I don't know

from what range float has this behavior?