How would you declare a named instance of a Font class, and what arguments can be used within the constructor? Show the declaration for a font named fancyFont that is size 24, bold, underlined, and Helvetica.
What will be an ideal response?
One version of the Font constructor requires two arguments: a string and a float. The string is the name of the font. The float represents the font size. For example:
bigFont = new Font("Courier New", 16.5f);
You also can create a Font using three arguments, adding FontStyle as in:
Font arialItalic = new Font("Arial", 24, FontStyle.Italic);
You can combine multiple styles using the pipe (|). For example, the following code creates a Font that is bold and underlined:
Font fancyFont =
new Font("Helvetica", 24, FontStyle.Bold | FontStyle.Underline);
You might also like to view...
Which of these is an example of optical storage media?
a. DVD b. SSD c. thumb drive d. a flash memory card
Which of the following computer applications alert users while entering or leaving a secure site?
a. Web server b. Antivirus c. Operating system d. Web browser