Marcos Vilela

+ Follow
since Jul 06, 2005
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Marcos Vilela

I would like to thanks everybody that helped me with my questions. I�ve just passed SCJP with 90%.

See you all.
The question is from Marcus Green mock exam..
Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?

Answer:Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type.

I didn't get why..
It's ambiguous because String and the other class are in different hierarchy so how the compile will know wich one is the most specific class? It's differet if you have one parameter as an OBject and another as a String. As we know String extends object, so String is more specific. If you pass null, the compiler will run the method that has a String as an argument.
I think I got the answer:

If a new Integer instance is not required, this method(valueOf()) should generally be used in preference to the constructor Integer(int), as this method is likely to yield significantly better space and time performance by caching frequently requested values.
no .. It compiles just fine..
What's the difference between:

Integer number = new Integer(10);
Integer number1 = Integer.valueOf(10);


How does it work?

What's happening?

if I try to find the object Fred for example I will receive a false return..

I'm a little bit confused.
Which of the following classes, will return elements in the order they were added (first in first out) when accessed via an iterator?

Vector. True
LinkedHashSet. True.

Why Vector?

output = Two , Ten , Three , One.

It's a little trick because if you use add with a position it will be wrong..

I need help..

if you don't override the equals() you are going to compare the objects reference, ==, as it was implemented in Object class, but you can override equals() an compare the object in the way you want. For example with the most important field...

The hashcode generate an int that identify in which bucket the object will be and if there are more then one object in the bucket, you are going to use the equals method to find the exactly object that you are looking for.

Correct me if I'm wrong..
String[][][] arr ={

{ { "a", "b", "c"}#arr[0][0]#, {"d", "e", null}#arr[0][1]# }, //arr[0][][]
{ {"x"}#arr[1][0]#, null }, //arr[1][][]
{ {"y"}#arr[2][0]#}, //arr[2][][]
{ { "z", "p"}#arr[3][0]#, {}#arr[3][1]# } //arr[3][][]


To get �y� -> String test = arr[2][0][0];
To get �null� ->String test1 = arr[0][1][2];

[ July 15, 2005: Message edited by: Marcos Vilela ]
[ July 15, 2005: Message edited by: Marcos Vilela ]
That's why we use a caught. To keep the code running.. It doesn't make sense stop after caught the exception.

I don't know if it's right..
correct me if I'm wrong.

[ July 15, 2005: Message edited by: Marcos Vilela ]
A Constructor with no arguments will be the default constructor?

Answer: False..

Why not?

== is false because NaN is not equal to anything, not even itself.

The point is: why a.equals(b) returns true?