注册 登录
TechRepubil.com.cn探客网
最具实践价值的IT应用分享平台
返回列表 回复 发帖

[讨论] SCJP考试试题解析二十二

SCJP考试试题解析二十二


我的QQ号:2535279


www.javaedu.com.cn

What does the following paint() method draw?

  1. public void paint(Graphics g) {

  2. g.drawString(“Any question”, 10, 0);

  3. }

  A. The string “Any question?”, with its top-left corner at 10,0

  B. A little squiggle coming down from the top of the component.

  解答:B

  点评:drawString(String str, int x, int y)方法是使用当前的颜色和字符,将str的内容显示出来,并且最左的字符的基线从(x,y)开始。在本题中,y=0,所以基线位于最顶端。我们只能看到下行字母的一部分,即字母‘y’、‘q’的下半部分。
返回列表