|
Technical Sample Questions : C |
C++ |
Oracle |
Java | Unix |
Operating Systems |
Data Structure
Java Sample Questions ›› Java AWT Sample Questions
Technical Java Sample Questions : Java AWT Sample Questions
Here we have provided some java AWT sample questions which are different from the EJB Sample Questions we referred to earlier. Let us solve them and also understand the difference between both of them.
- What is a Layout Manager and what are the different Layout Managers available in java.awt and what is the default Layout manager for the panel and the panel subclasses?
Answer: A layout Manager is an object that is used to organize components in a container. The different layouts available in java.awt are:
- FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion.
- BorderLayout: The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container.
- CardLayout: The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
- GridLayout: The elements of a GridLayout are of equal size and are laid out using the square of a grid.
- GridBagLayout: The elements of a GridBagLayout are organized according to a grid.However, the elements are of different sizes and may occupy morethan one row or column of the grid.
- Can I add the same component to more than one container?
Answer: No. Adding a component to a container automatically removes it from any previous parent (container).
- How can we create a borderless window?
Answer: Create an instance of the Window class, give it a size, and show it on the screen.
Frame aFrame = new Frame();
Window aWindow = new Window(aFrame);
aWindow.setLayout(new FlowLayout());
aWindow.add(new Button("Press Me"));
aWindow.getBounds(50,50,200,200);aWindow.show();
- Can I create a non-resizable windows? If so, how?
Answer: Yes. By using setResizable() method in class Frame.
- Which containers use a BorderLayout as their default layout? Which containers use a FlowLayout as their default layout?
Answer: The Window, Frame and Dialog classes use a BorderLayout as their default layout. The Panel and the Applet classes use the FlowLayout as their default layout.
- What is the difference between a MenuItem and a CheckboxMenuItem?
Answer: The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.
Java AWT sample questions are different from J2EE Sample Questions. Given above were some java AWT sample questions for your help. Keep checking back to know more about our next entry on Java Web Development Sample Questions.
« Previous
Java AWT Sample Question Number :
1-10|
11-16
|
|