Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
SELF TEST ANSWERS
Understanding Primitives, Enumerations, and Objects

1. You need to create an application that is used to calculate the attendance at a baseball game. What data type would be most appropriate for storing the attendance?

A. boolean

B. char

C. float

D. int

Answer:

Image D. The attendance of a baseball game is going to be a whole number within the range of an int.

Image A, B, and C are incorrect. A is incorrect because boolean variables are used to store literals with values of true or false. B is incorrect because the char data type is used to store a single Unicode character. C is incorrect because float is used to store floating-point numbers.

2. What is the best data type to use if you are required to perform many addition, subtraction, and multiplication calculations on a whole number?


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint