Core Java - Interview Questions and Answers

401. What is the sequence for calling the methods by AWT for applets?

Ans : When an applet begins, the AWT calls the following methods, in this sequence.
init( )
start( )
paint( )

402. Which method is used to output a string to an applet?

Ans : drawString ( ) method.

403. Every color is created from an RGB value.
True. / False

Ans : True.


404. How would you set the color of a graphics context called g to cyan?
a) g.setColor(Color.cyan);
b) g.setCurrentColor(cyan);
c) g.setColor("Color.cyan");
d) g.setColor("cyan’);
e) g.setColor(new Color(cyan));

Ans : a.

405. The code below draws a line. What color is the line?
g.drawLine(0, 0, 100,100);

Ans : d.

406. Which of the statements below are true?
A polyline is always filled.
b) A polyline can not be filled.
c) A polygon is always filled.
d) A polygon is always closed
e) A polygon may be filled or not filled

Ans : b, d and e.

407. What code would you use to construct a 24-point bold serif font?
a) new Font(Font.SERIF, 24,Font.BOLD);
b) new Font("SERIF", 24, BOLD");
c) new Font("BOLD ", 24,Font.SERIF);
d) new Font("SERIF", Font.BOLD,24);
e) new Font(Font.SERIF, "BOLD", 24);

Ans : d.

408. What does the following paint( ) method draw?

Public void paint(Graphics g) {
g.drawString("question #6",10,0);
a) A circle at (100, 100) with radius of 44
b) A circle at (100, 44) with radius of 100
c) A circle at (100, 44) with radius of 44
d) The code does not compile

Ans : d.

409. What is relationship between the Canvas class and the Graphics class?

Ans : A Canvas object provides access to a Graphics object via its paint( ) method.

410. What are the Component subclasses that support painting.

Ans : The Canvas, Frame, Panel and Applet classes support painting.

Post a Comment

Mới hơn Cũ hơn