aspose file tools*
The moose likes Mock Exam Errata and the fly likes Removed or Hidden Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Removed or Hidden" Watch "Removed or Hidden" New topic
Author

Removed or Hidden

yi miao
Greenhorn

Joined: Jun 29, 2001
Posts: 6

Code:
import java.awt.*;
public class TestFrame extends Frame
{
Button firstOne = new Button("One");
Button secondOne = new Button("Two");
public TestFrame()
{
add(firstOne,BorderLayout.NORTH);
add(secondOne,BorderLayout.NORTH);
setSize(400,400);
setVisible(true);
}
public static void main(String args[])
{
TestFrame tf = new TestFrame();
}
}
Question:
An Attempt to compile and run the above piece of code

A. Causes compilation error - a component cannot be added to region which is already occupied by another component.
B. Causes Runtime Exception - a component cannot be added to region which is already occupied by another component.
C. Neither A or B. The Frame comes up and only the button with label "Two" occupies the entire North region of the Frame.
D. Addition of secondOne causes firstOne to be removed from the container.
E. Addition of the secondOne causes the firstOne to be hidden in the container.
Answer: C&D. I know that C is correct. But I don't understand why D is correct, not E. I thought method only remove() removes conponents from a container.
Anoop Krishnan
Ranch Hand

Joined: May 03, 2001
Posts: 163
Hai Yi,
I think that the button 2 replaces the button 1 because you are adding both of them to the same location.That might be what the choice D signifies


I just want to know is there any body call my bean's Getter and Setter methods with "Please" in front - My favorite quip from Bugzilla
yi miao
Greenhorn

Joined: Jun 29, 2001
Posts: 6
Hello Anoop,
Yes, both of button 2 & button 1 were added to the same location. But my understand is that button 2 is right on the top of button 1, so it hides button 1. If button 1 is removed,
remove() method should be invoked.
 
jQuery in Action, 2nd edition
 
subject: Removed or Hidden