Saturday, 22 August 2009

Java Certification Question 0072

What best describes the appearance of an application with the following code?

import java.awt.*;

public class FlowAp extends Frame{

public static void main(String argv[]){

FlowAp fa=new FlowAp();

fa.setSize(400,300);

fa.setVisible(true);

}

FlowAp(){

add(new Button("One"));

add(new Button("Two"));

add(new Button("Three"));

add(new Button("Four"));

}//End of constructor

}//End of Application

1) A Frame with buttons marked One to Four placed on each edge.
2) A Frame with buutons marked One to four running from the top to bottom
3) A Frame with one large button marked Four in the Centre
4) An Error at run time indicating you have not set a LayoutManager


Answer 3) A Frame with one large button marked Four in the Centre

The default layout manager for a Frame is the BorderLayout manager. This Layout manager defaults to placing components in the centre if no constraint is passed with the call to the add method.

No comments: