Help coderanch get a
new server
by contributing to the fundraiser

Alex Radomski

Greenhorn
+ Follow
since Apr 24, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Alex Radomski

Plz lemme know if there's a way of determining the size of a zip file in bytes...
(can I use RandomAccessFile.length() for zip files?)


java.util.zip.ZipEntry has getCompressedSize()
21 years ago
Hi,
I'd say three String objects are created, Correct me if I'm wrong?


[ August 13, 2003: Message edited by: Alex Radomski ]
Hey,
This link might help: unicode webpage

[ August 12, 2003: Message edited by: Alex Radomski ]
Congratualtions Dharma Cris, hey everyone..
Hi Andres, check Bunkhouse XML-link if you haven't yet..?
I was debating myself which cert. to take next. But I think I'll go with the flow...and stick with SCJD.
[ August 04, 2003: Message edited by: Alex Radomski ]
congratulations
Excellent score!


21 years ago
Hi Unni,
When I run this code it does print all four lines...
Alex

Congratulations Penka!
21 years ago
Congratulations!

That's excelent score, at least in my books.
Have you asked yourself what's next??
Alex


21 years ago
This is tricky one.
I will put numbers with brief explanation. Follow the numbers to see the sequence.

1. H constructor called
2. compiler places default constructor for H class, which calls super constructor G().You can't see it because JVM places implicitly call.
3. G() constructor executes, calls printS1() method
4. prints s1 which is still uninitialized "null". Constructor at line 3 hasn't finished yet
Gee...It seems I can't indent the lines..

[ July 23, 2003: Message edited by: Alex Radomski ]
[ July 23, 2003: Message edited by: Alex Radomski ]

[ July 23, 2003: Message edited by: Alex Radomski ]
I think the answer to this is simpler than it looks.
I will expand on what has been already said.
When we create a string with: String s1 = "AB";
We create one String object that is placed in the string pool and the variable s1 reference address will lead you straight to the string pool.
Expl:
String s1 = "AB"; // and
String s2 = "A" + "B";
"AB" already in the pool, s2 will refer to the same address in the pool.
On the other hand when we create a string with: String s3 = new String ("AB");
We create one string object placed in the pool, and one in the non-pool which s3 will reference.
Bottom line:
When second String s1 = �AB�; is created reference s1 points to the same string in the string pool.
When String s2 = new String(�AB�); is created �s2� points to the new separate object (non-pool)
cheers

[ July 23, 2003: Message edited by: Alex Radomski ]
Hi Veena,
The best way to look at the instance operator is when object referred to by the variable reference on the left side of the instanceof (in this case c1) passes the IS-A test for the class on the right side.
---------------------------
I will expand with sample code. I hope this code will help you.
class A {}
class B extends A {}
class C extends B {
public static void main(String [] args)
{
C c1 = new C();
boolean b1 = c1 instanceof C; // true
boolean b2 = c1 instanceof B; // true
boolean b3 = c1 instanceof A; // true
boolean b4 = c1 instanceof Object; // All classes implicitly extend Object, so true
System.out.println(b1+","+b2+","+b3+","+b4);
}
}
[ July 22, 2003: Message edited by: Alex Radomski ]
From static code you are never allowed to access "directly" non-static code.
Expl: lab() // this will call static version of lab()
You access non static code through handle - (instance/reference variable) of the enclosing class. In this case: "js"
js.lab() // calls non static version

cheers
Alex
Yes, static is not allowed because the Inner class is declared inside the method.
You can view the local-method-inner-class as just another local member of the method, which is not allowed to be declared static, private, public etc...
Alex
Hi Barkat,
It does not get mentioned in equals() contract becuase it belongs to hashCode() contract.
Alex