a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 149|回复: 1

[考试试题] 2011年JAVA认证模拟题(39)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
 Q115 How many bytes does the following program write to temp.txt?   import java.io.*;
! X8 @' A) D, T  public class TestIOApp {
( u3 e6 p! b# K  G$ U7 F  public static void main(String args[])- d( y0 j& _3 b0 u7 B/ y2 s
  throws IOException {# |1 `' i4 H1 f% f, F5 t4 E& M
  FileOutputStream outStream = new
$ ~) f2 a4 M8 d& A& c% ^( u  FileOutputStream(“test.txt”);  _3 D8 U3 p- ^' J- ^& I
  String s = “test”;8 d2 z  {, R6 w; m& I* ~/ D
  for (int i=0; i6 I; i) N7 j: M
  outStream.write(s.charAt(i));1 E, J3 }1 o1 D; y3 m% n1 k
  outStream.close();
' y# [7 U3 n! j1 o) K" z  }0 o4 E3 ]' U+ g
  }  R+ O4 R' {% o2 [& M
  A 2 bytes/ Y% f) \3 g3 x8 c/ ?
  B 4 bytes
" c' d' Y' o4 B! `0 q  C 8 bytes
$ c3 D3 `( S5 u" K+ h# \% N  D 16 bytes
& h3 D/ O: D$ u, g  Q116 What is the output of the following program?# e$ Q- |( n# m
  import java.util.*;4 J4 t9 ?! [" C' b/ a: t
  class Question {  l3 J) f1 C: [$ ~: T; H( X
  public static void main (String args[])/ l+ v% A. z: R: N0 k5 {
  {! W! G9 {( S+ X' _& C
  TreeMap map = new TreeMap();  l! a5 l/ ^. z6 q" X, y
  map.put(“one”, “1”);
8 V1 J) v' ^; N3 T" Z. d  map.put(“two”, “2”);
3 [. X, i5 b5 p4 e  map.put(“three”, “3”);
$ x8 @/ q4 F+ w1 k  displayMap(map);8 v7 ?3 Z  _  V1 C
  }
* ?6 f8 F) K* N' C' m5 k  static void displayMap(TreeMap map) {7 q1 u9 ]: F3 L& e
  Collection c = map.entrySet();4 o" i8 n0 \: x! l" X
  Iterator i = c.iterator();) p6 @3 K% i# S" T
  while(i.hasNext()) {" E, @! b0 k+ W  x
  Object o = i.next();
: W8 Z$ q. d; `( ~1 ^9 H  E  System.out.print(o.toString());/ n3 c3 l! U; g+ |4 W# N
  }0 I, \$ v9 b' Y9 w
  }- Q" s( z2 H8 @2 Y
  }
+ I% ]3 g# d2 }2 c/ M- l% m2 L! d  A onetwothree
2 l$ _1 o) N4 f" m9 Z8 s% p  B 123
- p1 Y" O1 E% n3 u  C one=1three=3two=2% Z# s* ^2 S* b. V8 d

7 X+ H9 w# x: d* j, a  D onethreetwo
回复

使用道具 举报

 楼主| 发表于 2012-8-4 12:33:17 | 显示全部楼层

2011年JAVA认证模拟题(39)

</p>  Q117 Which lines of output are displayed by the following program?
6 G5 a( |, R. U% J( l9 t4 p  class Question {
0 e, B* e  E$ u* W. ^9 D0 k  public static void main(String [] args). `8 ]" {; Y) I+ |+ Q4 o
  {
- n1 Z* ]2 f. U% c- p  C* y0 C! U3 s! V
  for(int i=0; i
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-21 06:59 , Processed in 0.361483 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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