📄 answers.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html><head><title>Answers to Questions and Exercises: Object-Oriented Concepts</title><script language="JavaScript"><!-- hidefunction openWin(term) { url="../../../information/glossary.html#" + term; myWin= window.open(url, "Glossary", "width=400,height=150,scrollbars=yes,status=no,toolbar=no,menubar=no"); myWin.focus();}//--></script><STYLE type="text/css"><!--.FigureCaption { margin-left: 1in; margin-right: 1in; font-family: Arial, Helvetica, sans-serif; font-size: smaller; text-align: justify }--></STYLE> </head><body BGCOLOR="#ffffff" LINK="#000099"><B><FONT SIZE="-1">The Java</font><sup><font size="-2">TM</font></sup> <font size="-1">Tutorial</FONT></B><br><table width="550" summary="layout"><tr><td align="left" valign="middle"><a href="../QandE/questions.html" target="_top"><img src="../../../images/PreviousArrow.gif" width="26" height="26" align="middle" border="0" alt="Previous Page"></a><a href="../../TOC.html#concepts" target="_top"><img src="../../../images/TOCIcon.gif" width="26" height="26" align="middle" border="0" alt="Lesson Contents"></a></td><td align="center" valign="middle"><font size="-1"><a href="../../../index.html" target="_top">Start of Tutorial</a>><a href="../../index.html" target="_top">Start of Trail</a>><a href="../index.html" target="_top">Start of Lesson</a></font></td><td align="right" valign="middle"><font size="-1"><a href="../../../search.html" target="_top">Search</a><br><a href="http://developer.sun.com/contact/tutorial_feedback.jsp">Feedback Form</a></font></td></tr></table><img src="../../../images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" ALT=""><br><font size="-1"><b>Trail</b>: Learning the Java Language<br><b>Lesson</b>: Object-Oriented Programming Concepts </font><h2>Answers to Questions and Exercises: Object-Oriented Concepts</h2><blockquote></blockquote><h3>Answers to Questions</h3><blockquote> You can find the information needed to answer these questions in the API documentation for the <a target="_blank" href="http://java.sun.com/j2se/5.0/docs/api/java/awt/Color.html"><font color="#8800bb"><code>Color</code></font></a><a target="_blank" href="http://java.sun.com/j2se/5.0/docs/api/java/awt/Color.html"><img src="../../../images/apiIcon.gif" width=11 height=11 border=0 align="MIDDLE" alt=" (in the API reference documentation)"></a> class.<ol><li> <strong>Question</strong>: The ClickMe applet uses <code>Color.red</code> to set the drawing color to red. What other colors can you get by name like this?<br> <strong>Answer</strong>: black, blue, cyan, dark gray, gray, green, light gray, magenta, orange, pink, white, and yellow. <p> <li> <strong>Question</strong>: How would you specify other colors, like purple?<br> <strong>Answer</strong>: Construct a <code>Color</code> object for the color you want. The easiest way to do this is to specify the RGB values for the color you want. For example, purple is <code>Color(0.5, 0.0, 0.5)</code>.</ol></blockquote><h3>Answers to Exercises</h3><blockquote>To read explanations about the solutionsand to run the resulting applets,see<a target="_top" href="../ClickMeApplets.html">Getting Started</a><a target="_top" href="../ClickMeApplets.html"><img src="../../../images/tutorialIcon.gif" width=11 height=11 border=0 align="MIDDLE" alt=" (in the Learning the Java Language trail)"></a>.<ol><li> <strong>Exercise</strong>: Modify the applet to draw a green square instead of a red spot.<br> <strong>Answer</strong>: Look at our solution, contained in the<a target="_blank" href="ClickMeGreen.java"><font color="#bb000f"><code>ClickMeGreen.java</code></font></a><a target="_blank" href="ClickMeGreen.java"><img src="../../../images/sourceIcon.gif" width=11 height=11 border=0 align="MIDDLE" alt=" (in a .java source file)"></a> source file. <p><li> <strong>Exercise</strong>: Modify the applet to display your name in purple instead of a red spot.<br> <strong>Answer</strong>: Look at our solution, contained in the<a target="_blank" href="ClickMePurple.java"><font color="#bb000f"><code>ClickMePurple.java</code></font></a><a target="_blank" href="ClickMePurple.java"><img src="../../../images/sourceIcon.gif" width=11 height=11 border=0 align="MIDDLE" alt=" (in a .java source file)"></a> source file.</ol></blockquote><blockquote></blockquote><img src="../../../images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" ALT=""><br><table width="550" summary="layout"><tr><td align="left" valign="middle"><a href="../QandE/questions.html" target="_top"><img src="../../../images/PreviousArrow.gif" width="26" height="26" align="middle" border="0" alt="Previous Page"></a><a href="../../TOC.html#concepts" target="_top"><img src="../../../images/TOCIcon.gif" width="26" height="26" align="middle" border="0" alt="Lesson Contents"></a></td><td align="center" valign="middle"><font size="-1"><a href="../../../index.html" target="_top">Start of Tutorial</a>><a href="../../index.html" target="_top">Start of Trail</a>><a href="../index.html" target="_top">Start of Lesson</a></font></td><td align="right" valign="middle"><font size="-1"><a href="../../../search.html" target="_top">Search</a><br><a href="http://developer.sun.com/contact/tutorial_feedback.jsp">Feedback Form</a></font></td></tr></table><p><font size="-1"><a href="../../../information/copyright.html">Copyright</a>1995-2005 Sun Microsystems, Inc. All rights reserved.</font></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -