• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

2 AWT Qs, -- please help!

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would really appreciate it if someone could help explain the answers to the following.
--------------------------------------------------------------
1.What will be the appearance of an applet with the following init() method?
public void init() {
add(new Button("hello"));
}
A]nothing appears in the applet
B]a button will cover the whole area of the applet
C]button will appear in the top left corner of the applet
D]button will appear centred in the top region of the applet
E] button will appear in the center of the applet
--------------------------------------
3.Given the following code, which code fragments, when inserted at the indicated location, will succeed in making the program display a button spanning the whole window area?
import java.awt.*;
public class Q1e65 {
public static void main(String args[]) {
Window win = new Frame();
Button but = new Button("button");
// insert code fragment here
win.setSize(200, 200);
win.setVisible(true);
}
}
A]win.setLayout(new BorderLayout()); win.add(but)
B]win.setLayout(new GridLayout(1,1)); win.add(but)
C]win.setLayout(new BorderLayout());win.add(but,BorderLayout.CENTER)
D]win.add(but):
Ewin.setLayout(new FlowLayout()); win.add(but)
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
q1: answer is d)
q2: answer is a)b)c)d)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic