Search Suggest

Core Java - Interview Questions and Answers

421. You have created a simple Frame and overridden the paint method as follows.

public void paint(Graphics g){

g.drawString("Dolly",50,10);

}
What will be the result when you attempt to compile and run the program?
a) The string "Dolly" will be displayed at the centre of the frame
b) An error at compilation complaining at the signature of the paint method
c) The lower part of the word Dolly will be seen at the top of the form, with the top hidden.
d) The string "Dolly" will be shown at the bottom of the form

Ans : c.

422. Where g is a graphics instance what will the following code draw on the screen.

g.fillArc(45,90,50,50,90,180);
a) An arc bounded by a box of height 45, width 90 with a centre point of 50,50, starting
at an angle of 90 degrees traversing through 180 degrees counter clockwise.
b) An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting
at an angle of 90 degrees traversing through 180 degrees clockwise.
c) An arc bounded by a box of height 50, width 50, with a top left at coordinates of 45,
90, starting at 90 degrees and traversing through 180 degrees counter clockwise.
d) An arc starting at 45 degrees, traversing through 90 degrees clockwise bounded by a
box of height 50, width 50 with a centre point of 90, 180.

Ans : c.

423. Given the following code.

import java.awt.*;
public class SetF extends Frame{
public static void main(String argv[]){
SetF s = new SetF();
s.setSize(300,200);
s.setVisible(true);
}
}
How could you set the frame surface color to pink
a)s.setBackground(Color.pink);
b)s.setColor(PINK);
c)s.Background(pink);
d)s.color=Color.pink

Ans : a.


AWT: CONTROLS, LAYOUT MANAGERS AND MENUS

424. What is meant by Controls and what are different types of controls?

Ans : Controls are componenets that allow a user to interact with your application.
The AWT supports the following types of controls:
Labels
Push buttons
Check boxes
Choice lists
Lists
Scroll bars
Text components

425. The CheckboxGroup class is a subclass of the Component class.
True / False

Ans : False.

426. What are the immediate super classes of the following classes?
a) Container class
b) MenuComponent class
c) Dialog class
d) Applet class
e) Menu class

Ans : a) Container - Component
b) MenuComponent - Object
c) Dialog - Window
d) Applet - Panel
e) Menu - MenuItem

427. What are the SubClass of Textcomponent Class?

Ans : TextField and TextArea

428. Which method of the component class is used to set the position and the size of a component?

Ans : setBounds()

429. Which TextComponent method is used to set a TextComponent to the read-only state?

Ans : setEditable()

430. How can the Checkbox class be used to create a radio button?

Ans : By associating Checkbox objects with a CheckboxGroup.



إرسال تعليق