=========================preview======================
(COMP201)comp201_01f_midterm_sol.pdf
Back to COMP201 Login to download
======================================================
.............................................
............................
.
..........
....................
......................
.
.
............... . ................ .........................................
..
.
.................. . . .........................................
.
.
.
..............
.
... ................................................ ... .............................................................. ... ......................................................................................... ... ....................
......... ....................
.. ..........
.. ........
.. .......
.. ......
.. ...
.. ...
.. .....
.. ...
.. ....
... ....
....... ........
.....................................................................................
.....................................................................
String strA = new String("Mid-Autumn ");
String strB = new String("Festival ");
strA = strB;
System.out.print ( strA );
System.out.println( strB );
......Mid-Autumn Festival. ......Festival Mid-Autumn. ......Mid-Autumn .Mid-Autumn. ......Festival Festival.
...............................................................
............................................
String strA = new String("Steamed ");
strA = new String("Toasted ");
strA = new String("Fried ");
strA = new String("Baked ");
strA = new String("Beef ");
........................................................................................................ .................................. .......................................... ...................................... ...................................... ......................................
................................................................
................................
StringTokenizer stuff = new StringTokenizer( "abc,def,ghi", "," );
System.out.println( stuff.nextToken() );
................... ........... ............ .........
...............................................................
...................Rodent...................Rat.........................Mouse........Mouse............. ......PocketMouse.........................
Rodent rod;
Rat rat = new Rat();
Mouse mos = new Mouse();
PocketMouse pkt = new PocketMouse();
.........................................................
a.
rod = rat;
b.
rod = mos;
c.
pkt = null;
d.
pkt = rat;
................................................................
............................................................................................................. .........................................................Rat..Mouse......PocketMouse...
a.
Rat[] array = new Rat[10];
b.
Rodent[] array = new Rat[10];
c.
Rodent[] array = new Rodent[10];
d.
Rodent[10] array;
...............................................