Chapter 2. Working with Java data types

 

This chapter covers:

  • [2.2] Differentiate between object reference variables and primitive variables. The primitive data types in Java, including scenarios when a particular primitive data type should or can’t be used. Similarities and differences between the primitive data types. Similarities and differences between primitive and object reference variables.
  • [2.1] Declare and initialize variables (including casting of primitive data types). Declaration and initialization of primitives and object reference variables. Literal values for primitive and object reference variables.
  • [2.5] Develop code that uses wrapper classes such as Boolean, Double, and Integer. How and when values are boxed and unboxed when used with wrapper classes.
  • [3.1] Use Java operators; including parentheses to override operator precedence. Use of assignment, arithmetic, relational, and logical operators with primitives and object reference variables. Valid operands for an operator. Output of an arithmetic expression. Determine the equality of two primitives. How to override the default operator precedence by using parentheses.

Imagine that you’ve just purchased a new home. You’ll likely need to buy different-sized containers to store different types of food items, because one size can’t fit all. Also, you might move around food items in your home—perhaps because of a change in the requirements over time (you wish to eat it or you wish to store it).

2.1. Primitive variables

 
 

2.1.1. Category: Boolean

 
 

2.1.2. Category: signed numeric

 
 
 

2.1.3. Category: character (unsigned integer)

 
 

2.1.4. Confusion with the names of the primitive data types

 

2.2. Identifiers

 
 

2.2.1. Valid and invalid identifiers

 

2.3. Object reference variables

 

2.3.1. What are object reference variables?

 
 
 

2.3.2. Differentiating between object reference variables and primitive variables

 
 

2.4. Operators

 
 
 
 

2.4.1. Assignment operators

 
 
 

2.4.2. Arithmetic operators

 
 
 
 

2.4.3. Relational operators

 
 
 

2.4.4. Logical operators

 
 

2.4.5. Operator precedence

 
 
 
 

2.5. Wrapper classes

 
 
 
 

2.5.1. Class hierarchy of wrapper classes

 

2.5.2. Creating objects of the wrapper classes

 
 
 

2.5.3. Retrieving primitive values from the wrapper classes

 
 
 

2.5.4. Parsing a string value to a primitive type

 
 
 
 

2.5.5. Difference between using the valueOf method and constructors of wrapper classes

 
 
 

2.5.6. Comparing objects of wrapper classes

 

2.5.7. Autoboxing and unboxing

 
 

2.6. Summary

 
 
 
 

2.7. Review notes

 
 
 

2.8. Sample exam questions

 
 
 

2.9. Answers to sample exam questions

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage