This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!

Huasong Yin

Greenhorn
+ Follow
since Feb 08, 2001
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 Huasong Yin

Dont forget Strategy and Decorator!
Decorator is heavily used in AWT and Swing. ScrollPane and JScrollPane are Decorators. The high-level Stream classes are also Decorators.
The LayoutManagers are Strategies.
His article is not as in depth as that of Gamma's. I think that he didnt put much effort in hacking patterns in Java.
Here again is my trial for Mark's question:
1. If my Class M needs to inherit from class A, I would first decide whether M needs to have the full or partial functionality of A. Use inheritence if M behaves fully like A. Use composition if M only inherits partial behaviors from A and delegate bahaviors to the corresponding member field. For example:
class ButtonWindow extends Frame {
Button b;
public void setButtonText(String s){
b.setText(s);
}
public void addActionListener(ActionListner a){
b.addActionListener(a);
}
//other members
}
The key is to maintaion a balance between inheritence and delegation.
2. In Java there is only one class to inherit from, choosing the appropriate superclass will be the major task.
18 years ago
This is a great interview question. Here is my trial of an answer.
1. I would prefer interface over abstract class if all the data fields are static constants and I do not expect any subtypes to have default behaviours.
2. More importantly if I expect subtypes can inherit from any other classes. This is the reason given by previous posting. For example, I can implement my Frame to be an ActionListener. But if ActionListener were declared as an abstract class, I would have to extend ActionListener instead of Frame. **So Interface must be used in order to support multiple inheritence**.
18 years ago
I am a Sun certified Java 2 programmer with strong problem-solving skills.
My skill set includes:
*JDBC, Servlets, Swing, Visual Cafe
*VB/VBscript, SQL Server
*C/C++ , OOA/OOD/UML
Not very experienced, but with a quick-learning mind
My education includes PhD in Mathematics and MS in Artificial Intelligence.
I live in Georgia now. Looking for US employment that can provide **H-1 sponsorship**. Preferred location is the South, East area, but I am willing to relocate to anywhere in US.
Huasong Yin
yinhuasong@hotmail.com
------------------
19 years ago
A and C are both correct.
C is correct because that all methods in an Interface should be declared public. They are implicitly abstract whether you declare it or not.

Originally posted by Charlie Swanson:
Which of the following is correct ? Select all correct answers.
A. The native keyword indicates that the method is implemented in another language like C/C++.
B. The only statements that can appear before an import statement in a Java file are comments.
C. The method definitions inside interfaces are public and abstract. They cannot be private or protected.
D. A class constructor may have public or protected keyword before them, nothing else.
The Correct answers were A and B.
I disagreed with B due to the fact that packages are stated befor
the import.
Can anyone please explain why B is correct and my answer was incorrect.