S A M P L E CPS 1 (Ramm) Spring 1998 4 February 1998 Quiz #3 Name ___________________ Honor Code________________________ Section _____ (Note: Getting your Name and Section right is worth one point. If we can't decipher your name or section, it's wrong.) public class StringPlay extends java.applet.Applet { TextField mInstruct, mFirst,mMid, mLast, mFull, mInit, gmFirst, gmMid, gmLast; Button bEnter; String sFirst, sMid, sLast, sInit, sFull; int length; public void init () { mInstruct = new TextField(72); mInstruct.setText("Please enter your full name in the fields below." + " Then click Enter."); mFirst = new TextField(9); mFirst.setText("First:"); mMid = new TextField(9); mMid.setText("Middle:"); mLast = new TextField(9); mLast.setText("Last:"); gmFirst = new TextField(60); gmMid = new TextField(60); gmLast = new TextField(60); mFull = new TextField(72); mInit = new TextField(72); bEnter = new Button("Enter"); add(mInstruct) ; add(mFirst) ; add(gmFirst) ; add(mMid) ; add(gmMid) ; add(mLast) ; add(gmLast) ; add(bEnter) ; add(mFull) ; add(mInit) ; } public boolean action(Event e,Object obj) { if (e.target == bEnter) { sFirst = gmFirst.getText(); sMid = gmMid.getText(); sLast = gmLast.getText(); sFull = sFirst + " " + sMid + " " + sLast; mFull.setText("Your full name is: " + sFull); sInit = sFirst.substring(0,1) + sMid.substring(0,1) + sLast.substring(0,1); length = sFirst.length() + sMid.length() + sLast.length(); mInit.setText("Your initials are: " + sInit + ". The number of characters in your name is " + length); return true; } return false; } } : A. Assume that the program above was run, and the person entered the names John Andrew Robinson for first middle and last names and the clicked on the Enter button. In the action method above, what are the values in: sMid _________ sFull _____________ sInit _________ length ____________ B. What would be the problem if we moved the gmFirst.getText() method invocation to the init method? C. possible other questions in the same spirit.