a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 154|回复: 0

[考试试题] 2011年JAVA认证模拟题第二阶段(21)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  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?5 t! J# n; {$ T( ~
  a. Canvas c = new Canvas(new GridLayout(2,3));, D9 E) K+ t2 U7 \3 O. F) q
  b. Panel p = new Panel(new GridLayout(2,3));$ L! n# Y3 V( _( n; D/ N9 G
  c. Window w = new Window(new GridLayout(2,3));
! k/ b, Q7 y0 a1 B# ^  d. Panel p = new Panel(new GridLayout(3,2));& l! F  m; J; ~& Y( S1 g
  Q62.The following lists the complete contents of the file named Derived.java
% L  O. X2 f- ^% ]3 r  1. public class Base extends Object {, j' s+ G2 {: E8 s+ A
  2. String objType;) `  F' y- I1 P7 t0 j1 e
  3. public Base() { objType = “I am a Base type” ; }5 A( {9 S. r  X  j" O6 H/ U
  4. }! O+ o1 X- X0 }5 j$ j
  5. public class Derived extends Base {8 x2 a, P. H9 ^/ c+ ]* Y' i. h
  6. public Dervied() { objType = “I am a Dervied type”; }
) H/ M5 \1 F& R+ a' C; o  8. public static void main(String args[]) {# R5 F. F* h8 R1 k
  9. Dervied d = new Derived();
( ^: G0 {3 `9 b& H2 t: f9 n  10. }! Z& M) d, ]* D4 C; y  O- e
  11. }
7 a4 p- [! d' Y* G2 {1 p" r  What will happen when this file is compiled?+ B3 W3 a; A1 r) X1 S9 N$ v! e& b  E
  a. Two class files,Base.class and Derviedc* G- U  B" ?  b7 o* `1 R6 b& h$ y  e( c& C
        lass, will be created.
. {$ |6 f6 K/ o# w4 F
6 p: L) h0 ?; q( X9 _  b. The compiler will object to line 1.! b( o9 u" L; j3 P* y6 V
  c. The compiler will object to line 5.
7 b; T% e. {# h5 M  d. The compiler will object to line 2.
/ C3 H  `; ^/ a  ~# `3 w  Q63.Your mouseDragged() event handler and your paint method look like this* z& N% g  b: f6 b  E
  1. public void mouseDragged(MouseEvent e) {; d8 ^7 @3 B- B' c
  2. mouseX = e.getX();
+ o3 C2 b0 X' y" ]  \  3. mouseY = e.getY();
4 v: d; I# }) D+ a  t. G4 x" d- T7 z  4. repaint();
1 C" o5 Z# t- a- k; g4 U' C  5. }
* r! f) t+ u5 ^' Q7 d$ C  6. public void paint(Graphics g) {& T- D+ s' c7 `0 H' {
  7. g.setColor(Color.cyan);3 S' H! `. w! ~) m
  8. g.drawLine(mouseX,mouseY,mouseX+10,mouseY+10);- U5 Z/ S! ?+ B! @
  9. }
: T' F7 z: U: {0 u7 a$ ?( ?  D  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?
7 M$ u4 D6 A* j/ r  N0 m  s: x  a. On line 4, replace repaint() with paint().0 N% ^; B( G" N8 S
  b. On line 4, replace repaint() with update()., c5 t& L  q9 ^1 p+ |; F" y7 U
  c. After line 7, add this super.update(g);
6 U$ j5 g) C# _: A: K  d. Add public void update(Graphics g) { paint(g); }/ m% v( O- P) L- H
  61. b* ?9 ^* [* ~3 q/ J( i# K7 j. e
  62. b# m5 Y# V2 D# h# V- v/ t6 z
  63. d
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-22 03:50 , Processed in 0.296958 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表