ࡱ> Y[X` bjbjss 26 < 4 BL\\\\777&B(B(B(B(B(B(B$CDhFLB77777LB\\aB7\\&B7&B=Dz@\ @co >&&BwB0B>}G}GLz@z@}GA7777777LBLB777B77774" LAB 6 - Introduction to Programming (part 1) Lab Exercises Topics Introduction to Programming Class and Object Methods Exercises 3.3 Class and Object Methods What is the value printed at each step? String str1 = Hello World; System.out.println(str1.length()); System.out.println(str1.toLowerCase()); System.out.println(str1.toUpperCase()); str1 = Goodbye World; char ch = str1.charAt(5); System.out.println(ch); str1 = Computer + Science; System.out.println(str1); str1 = str1.concat( is fun); System.out.println(str1); str1 = "smiles".substring(1, 5); System.out.println(str1); Try typing the statements into the interaction pane to check your answers. A complete list of String methods can be found at the API ( HYPERLINK "http://java.sun.com/j2se/1.5.0/docs/api/index.html" http://java.sun.com/j2se/1.5.0/docs/api/index.html) What is the value printed at each step? int nbr1 = -37; double nbr2 = 23.45; System.out.println(Math.abs(nbr1)); System.out.println(Math.sqrt(nbr2)); System.out.println(Math.ceil(nbr2)); System.out.println(Math.sin(nbr1)); System.out.println(Math.min(nbr1, nbr2)); System.out.println(Math.round(nbr2)); Try typing the statements into the interaction pane to check your answers. A complete list of Math methods can be found at the API ( HYPERLINK "http://java.sun.com/j2se/1.5.0/docs/api/index.html" http://java.sun.com/j2se/1.5.0/docs/api/index.html) What is the value printed at each step? System.out.println(Integer.MAX_VALUE); System.out.println(Integer.MIN_VALUE); System.out.println(Integer.toHexString(250)); System.out.println(Integer.toBinaryString(250)); System.out.println(Character.isDigit(a)); Try typing the statements into the interaction pane to check your answers. A complete list of Integer, Character, Boolean, Byte, Double, Float, Long, and Short methods can be found at the API ( HYPERLINK "http://java.sun.com/j2se/1.5.0/docs/api/index.html" http://java.sun.com/j2se/1.5.0/docs/api/index.html) Copy the following program into the definition pane, compile and execute. //******************************************************************** // RandomNumbers.java Author: Lewis/Loftus // // Demonstrates the creation of pseudo-random numbers using the // Random class. //******************************************************************** import java.util.Random; public class RandomNumbers { //----------------------------------------------------------------- // Generates random numbers in various ranges. //----------------------------------------------------------------- public static void main (String[] args) { Random generator = new Random(); int num1; float num2; num1 = generator.nextInt(); System.out.println ("A random integer: " + num1); num1 = generator.nextInt(10); System.out.println ("From 0 to 9: " + num1); num1 = generator.nextInt(10) + 1; System.out.println ("From 1 to 10: " + num1); num1 = generator.nextInt(15) + 20; System.out.println ("From 20 to 34: " + num1); num1 = generator.nextInt(20) - 10; System.out.println ("From -10 to 9: " + num1); num2 = generator.nextFloat(); System.out.println ("A random float (between 0-1): " + num2); num2 = generator.nextFloat() * 6; // 0.0 to 5.999999 num1 = (int)num2 + 1; System.out.println ("From 1 to 6: " + num1); } } A complete list of Random methods can be found at the API ( HYPERLINK "http://java.sun.com/j2se/1.5.0/docs/api/index.html" http://java.sun.com/j2se/1.5.0/docs/api/index.html) QUESTIONS: Write a statement that prints the number of characters in a String object called overview. Write a declaration for a String variable called change and initialize it to the same characters stored in another String called original with all e characters changed to j. Write an assignment statement that computes the square root of the sum of num1 and num2 and assigns the result to num3. Write code to declare and instantiate an object of the Random class and use nextInt to generate a random number between 1 and 6. What are the MAX_VALUE for Byte and MIN_VALUE for Short? Submit the answers through the DropBox in WebCT. #$*+,-:;ABCwxyŴxfWJ?hj75OJQJ^Jhwkhj7OJQJ^Jh+5CJOJQJ^JaJ#hKh+5CJOJQJ^JaJhPyOJQJ^JhnqIOJQJ^Jhj7OJQJ^Jhwk5B*\mH phsH h+5B*\mH phsH  h+5>*B*\mH phsH h+%h+5B*CJ$\aJ$mH phsH h}hnqICJ0aJ0h.0CJ0aJ0hTCJ0aJ0h}CJ0aJ0-;C_xy 5 ^ _ x ed/gded/gdo6ged/gdnqIed/gdwkdd[$\$ed/gd+$a$ed/  2 3 4 5 6 I [ \ ] ^ _ ` w x $ F G H c d ߾Ⱦ߾Ⱦߴߴߧߧ߾jhOJQJU^JhOJQJ^JheOJQJ^Jh['h['OJQJ^Jh['OJQJ^Jho6gOJQJ^Jho6gho6gOJQJ^JhOJQ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JQJ^JhI>OJQJ^JheOJQJ^J dd[$\$ed/gdK 7$8$H$ed/gdK01h/R / =!"#$% ADyK 3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlyK fhttp://java.sun.com/j2se/1.5.0/docs/api/index.htmlADyK 3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlyK fhttp://java.sun.com/j2se/1.5.0/docs/api/index.htmlADyK 3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlyK fhttp://java.sun.com/j2se/1.5.0/docs/api/index.htmlADyK 3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlyK fhttp://java.sun.com/j2se/1.5.0/docs/api/index.html@@@ NormalCJ_HaJmH sH tH N@2N Heading 3dd@&[$\$5CJ\aJDA@D Default Paragraph FontRi@R  Table Normal4 l4a (k@(No ListB^@B Normal (Web)dd[$\$4U@4 Hyperlink >*phDV@D FollowedHyperlink >*phe@" HTML Preformatted7 2( Px 4 #\'*.25@9CJOJQJ^JaJDZ`2D  Plain TextCJOJQJ^JaJ6 n Rn eMnR-;C_xy 5^_x $&Hcdbc'(MNyzIJ|}/0wF G ` a | ~ ? j o   8 k l ' ( Q , H { 7:ERK444444(44444444444444444444444444444444444444444444444444444444444444<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<4<444<44V4V444444< & J  (,_&hl 4XXXX8@0(  B S  ?-01:;A 6H~ /@I[);<DOabj{-.AK]^t~{N ^ n { d h ! 2 > P y 5 F W i  : = N ` HI  6Iy} 7AI\)<Ob{.K^~xG M a g B H ! 3 y 5 G  = B ::::::::::::::::::::::::::::::::::::::::Cy`wyIc{K~a ~ :EHI4hG|{ Zh6 '7(*|")l' o..Y=X^B)~kJ)4Xd6rjk3_e26aޫ)iP(,lMl/D{l^`CJOJPJQJ^Jo(^`OJQJ^Jo(hHopp^p`OJQJo(hH@ @ ^@ `OJQJo(hH^`OJQJ^Jo(hHo^`OJQJo(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Jo(hHo^`OJQJo(hH^`OJQJo(hH^`OJQJ^Jo(hHoPP^P`OJQJo(hH^`o() ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`hH. PLP^P`LhH. ^`OJQJo(n ^`OJQJo( pp^p`OJQJo(n @ @ ^@ `OJQJo(n ^`OJQJo(n ^`OJQJo(n ^`OJQJo(n ^`OJQJo(n PP^P`OJQJo(n ^`OJQJo( ^`OJQJo( pp^p`OJQJo( @ @ ^@ `OJQJo( ^`OJQJo( ^`OJQJo( ^`OJQJo( ^`OJQJo( PP^P`OJQJo(.X^B*|"~kJ|{4X)i6 26aY=7lMl/D{4hk3_l'j        C                         ~v        膊$^NX4(vX@\,X6E                :߼zܷ\_ e4 "Q/R4FCV:| LLhNR6ғL,/ }pu / 6$pWuw&}pu&&}puT '}puf'/t*/R4z>Fu^RCR4;Q[pWuZf;]}pu#]kpWuz>Fu/}puf'pWu>}T}R4>}/! K+x #J1:5\7 B9nqIde@Ze9fo6gwks]qVqu|Py['.0}j7To" I>qM&L=c@JJ<JJp@UnknownG: Times New Roman5Symbol3& : Arial3z Times5CMTT10?5 z Courier New;Wingdings"qh㻸]]u>4 3QLX(?o"2:LAB 1 - Introduction to Computers and Computer Programming wayne summers wayne summersL           Oh+'0 4 LX x   <LAB 1 - Introduction to Computers and Computer Programmingwayne summers Normal.dotwayne summers2Microsoft Office Word@F#@ʟ@M@M]՜.+,D՜.+,< hp  Columbus State University ;LAB 1 - Introduction to Computers and Computer Programming Title 8@ _PID_HLINKSAtg+ 3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlg+3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlg+3http://java.sun.com/j2se/1.5.0/docs/api/index.htmlg+3http://java.sun.com/j2se/1.5.0/docs/api/index.html  !"#%&'()*+,-./0123456789:;<=>?@ABCDEFGIJKLMNOQRSTUVWZRoot Entry Fxo\Data 1Table$GWordDocument26SummaryInformation(HDocumentSummaryInformation8PCompObjq  FMicrosoft Office Word Document MSWordDocWord.Document.89q