会计考友 发表于 2012-8-4 12:33:16

2011年JAVA认证模拟题第二阶段(21)

  Q61.You need a container to hold six equal-sized button in the three columns of two. This arrangement must persist when the container is resized. Which of the following will create the that container?
  a. Canvas c = new Canvas(new GridLayout(2,3));
  b. Panel p = new Panel(new GridLayout(2,3));
  c. Window w = new Window(new GridLayout(2,3));
  d. Panel p = new Panel(new GridLayout(3,2));
  Q62.The following lists the complete contents of the file named Derived.java
  1. public class Base extends Object {
  2. String objType;
  3. public Base() { objType = “I am a Base type” ; }
  4. }
  5. public class Derived extends Base {
  6. public Dervied() { objType = “I am a Dervied type”; }
  8. public static void main(String args[]) {
  9. Dervied d = new Derived();
  10. }
  11. }
  What will happen when this file is compiled?
  a. Two class files,Base.class and Derviedc
      lass, will be created.

  b. The compiler will object to line 1.
  c. The compiler will object to line 5.
  d. The compiler will object to line 2.
  Q63.Your mouseDragged() event handler and your paint method look like this
  1. public void mouseDragged(MouseEvent e) {
  2. mouseX = e.getX();
  3. mouseY = e.getY();
  4. repaint();
  5. }
  6. public void paint(Graphics g) {
  7. g.setColor(Color.cyan);
  8. g.drawLine(mouseX,mouseY,mouseX+10,mouseY+10);
  9. }
  You want to modify your code so that the cyan lines accumulate on the screen, rather than getting erased every time repaint() calls update(). What is the simplest way to proceed?
  a. On line 4, replace repaint() with paint().
  b. On line 4, replace repaint() with update().
  c. After line 7, add this super.update(g);
  d. Add public void update(Graphics g) { paint(g); }
  61. b
  62. b
  63. d
页: [1]
查看完整版本: 2011年JAVA认证模拟题第二阶段(21)