This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!

Metal Zhang

Ranch Hand
+ Follow
since Aug 05, 2001
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 Metal Zhang

O,I can not open this site.

Originally posted by Guoqiao Sun:
Feedback is welcome, hope it helps. You can find it at:

Java lover from hell!
[This message has been edited by Metal Zhang (edited September 19, 2001).]
I created a java.awt.Frame object as the main window of my application.And I also want to create a children window when I click the button in the main window.Ok,I can do that.But I found the children window always appear in the top-left of the screen.
I don't like this appearance.So I want to know how to create a children Window and let it appear as the dimension of the the main Window's client area?
Any advice willbe greatly appreciated!
Java lover from hell!
17 years ago
Thank you!

Originally posted by Paul Stevens:

Java lover from hell!
17 years ago
Explain what?

Java lover from hell!
O,I see.Your explanations are quit good.Thank you all!

Originally posted by Shyamsundar Gururaj:
Hello Jodi and Zhang,
Before saying anything, let me state a small preamble...
I am sure that you'll know this already..."Constructors are invoked in the reverse order to the call order".
Now coming to your post...
My understanding of the [b]super()
concept says...
super() or this() can be used only in a constructor definition and, if used, must be the first statement in the constructor.
If the first statement in your subclass constructor is neither super() nor this(), the compiler inserts an implicit super() statement to invoke the default constructor of your base class. (Please refer to Michael's post above.)
Now, these properties have certain ramifications...
One is, if the superclass does not define a default constructor but only provides non-default ones, then the subclass constructor cannot afford to have its first statement other than a this() or a specific super() with the right arguments to invoke the matching constructor.
In other words, if the compiler sees that the subclass constructor does not have a super() or a this() construct, it will insert an implicit super() statement. But to its dismay, it'll not find a corresponding default constructor in the superclass causing it to scream profanities at the code
The other ramification is that if the subclass does not have any declared constructors AND the superclass does not have a default constructor, the compiler will definitely not like it as the implicit default super() it generates in the subclass will not find a match in the superclass.
Now, coming to the code that you had posted...

In line 2, your code defines a constructor, it does neither have a super() nor a this() construct. So the complier will insert an implicit super() But assuming that there is no default constructor in the Base class, this will generate a compile-time error as there will be no match for the implicit super() . So, in order for the code to compile, there needs to be a Base() { } statement in the base class.
And of course, the constructor in line 4 will work fine if the constructor Base(int j, int k) { } exists in the superclass.
Hope this helps!
[This message has been edited by Shyamsundar Gururaj (edited September 03, 2001).][/B]

Java lover from hell!
I have a Frame object which represents a window.And I construct a dialog in which there is a button.Now I want to end the dialog window but not the frame window when I click the button.I don't know how to perform this operation.Your advisor will be greatly appreciated!
Java lover from hell!
17 years ago
I think if we need do something in the super class's constructor,then the default constructor is needed or the default constructor need not be explicitly defined.I don't
know the reason why answer A is correct?

Originally posted by Jordi Marqu�s:
This question is from Sun web:
Consider the following class definition:
1. public class Test extends Base {
2. public Test(int j) {
3. }
4. public Test(int j, int k) {
5. super(j, k);
6. }
7. }
Which of the following forms of constructor must exist explicitly in the definition of the Base class?
A. Base() { }
B. Base(int j) { }
C. Base(int j, int k) { }
D. Base(int j, int k, int l) { }
The answere is A and C but I don�t understand why C is correct because the code will compile wihtout constructor A, because is not necessary.
Thank you in advance

Java lover from hell!
Please try to compile and run this code:

The output is:
I think it is a good example to prove the question.And if you try to compile this code:

The compiler will complain: The type type Foo can't be private. Package members are always accessible wi
thin the current package.
private interface Foo{
1 error

Java lover from hell!
Yes,I think you are quite right.

Originally posted by leena rane:
Yes,d is not correct answer.
break can be used in 3 ways: switch stmt. break from a loop. break from a block e.g. C in the question.
But a continue can be used only in one way:
in a loop.
Just a tip (hope it helps)
when we say,continue,we mean continue with the NEXT iteration of this loop(skipping the rest of the present iteration).As far as a block of code is concerned it is anyway going to be executed just once.Continue with next iteration,would not make sense.

Java lover from hell!
Ok,I got it understood.Thank you all!

Originally posted by Ilja Preuss:
To clarify:
You normally only have one copy of a class in memory, but multiple instances (objects) of it. All these objects share the same definition of the methods, only the data (nonstatic fields and local varibles) need to be separated.

Java lover from hell!
17 years ago
You can try this code:

The output will be:

a = (heart-shape signal)
b = 3

Now,we can draw a conclusion:If you need the char variable to appear as an integer,it will be what you want.And by default,it is still a char variable.

Originally posted by Wasim Ahmed:
Here is the code.
String s=new String("Bicycle");
int iBegin=1;
char iEnd=3;
Output is ic
I think signature of substring method is substring(int x,int y);
How is the char got converted to int?

Java lover from hell!
[This message has been edited by Metal Zhang (edited August 28, 2001).]
I tried your code,but I found the compilation will not pass under all kinds of situations.The errors are the same: Exception is never thrown in the body of the corresponding try statement.
catch ( e)
1 error

Originally posted by Honggui Li:
I got some question for ya :
public class A
public static void main(String a[ ])
// { }
// { return; }
// { ; }
catch ( e)
{ Sytem.out.println("e"); }
question: if we uncomment the first { } ,compile fail.
if we uncomment the second { retun;},(of course we comment the other two line ) it will compile and run . I don't know what will happen if we uncomment the third one.
Can anyone explain that ?
Thanks a lot.

Java lover from hell!
[This message has been edited by Metal Zhang (edited August 23, 2001).]
I compiled them but failed.The error is: '{' expected.
public class Test1() {
1 error

Originally posted by Christy Smith:
Ernest, I believe for question#2, the code is okay, no compilation error is generated. Please correct me if I am wrong.

Java lover from hell!
[This message has been edited by Metal Zhang (edited August 23, 2001).]
The main method in Q18 is not be defined correctly.Can you see the missed code in the method definition line?
It is just "(String args[])" after "main".So the code of Q18 will not be compiled.
Am I wrong?

Originally posted by Ashik uzzaman:
[B]Well Ernest, very good picks frm the bunch of grasses!
In ur Q5 u have to import ernie.B or ernie.* or have to use ernie.A--otherwise compile time error. Q11 i agree with Cameron's answer as well as ur explanation. But Q18 will not fail to compile....try the following code. It will both compile and run fine! Anyway, best wishes for ur exam. I m appearing 27th, when r u???


Java lover from hell!
Yes,I think you are right.I tried it!

Originally posted by Muhammad Farooq:
I think answer 3 and 5 are correct, try compiling with the modification asked in option 5.

Java lover from hell!