Core Java - Interview Questions and Answers

451. The List component does not generate any events.
True. / False.

Ans : False.

452. Which components are used to get text input from the user.

Ans : TextField and TextArea.

453. Which object is needed to group Checkboxes to make them exclusive?

Ans : CheckboxGroup.

454. Which of the following components allow multiple selections?
a) Non-exclusive Checkboxes.
b) Radio buttons.
c) Choice.
d) List.

Ans : a and d.

455. What are the types of Checkboxes and what is the difference between them?

Ans : Java supports two types of Checkboxes.
They are :
Exclusive and Non-exclusive.
In case of exclusive Checkboxes, only one among a group of items can be selected at a time. I f an item from the group is selected, the checkbox currently checked is deselected and the new selection is highlighted. The exclusive Checkboxes are also called as Radio buttons.
The non-exclusive checkboxes are not grouped together and each one can be selected independent of the other.

456. 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 panal and the panal subclasses?

Ans: A layout Manager is an object that is used to organize components in a container.
The different layouts available in java.awt are :
FlowLayout, BorderLayout, CardLayout, GridLayout and GridBag Layout.
The default Layout Manager of Panal and Panal sub classes is FlowLayout".

457. Can I exert control over the size and placement of components in my interface?

Ans : Yes.


458. Can I add the same component to more than one container?

Ans : No. Adding a component to a container automatically removes it from any previous parent(container).

459. How do I specify where a window is to be placed?

Ans : Use setBounds, setSize, or setLocation methods to implement this.

setBounds(int x, int y, int width, int height)
setBounds(Rectangle r)
setSize(int width, int height)
setSize(Dimension d)
setLocation(int x, int y)
setLocation(Point p)

460. How can we create a borderless window?

Ans : Create an instance of the Window class, give it a size, and show it on the screen.

eg. Frame aFrame = ......
Window aWindow = new Window(aFrame);
aWindow.setLayout(new FlowLayout());
aWindow.add(new Button("Press Me"));

Post a Comment

Mới hơn Cũ hơn