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 |