Chapter 2. Working with Java data types

Exam objectives covered in this chapter

What you need to know

[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).

Your new kitchen is an analogy for how Java stores its data using different data types, and manipulates the data using operators. The food items are like data types in Java, and the containers used to store the food are like variables in Java. The change in the requirements that triggers a change in the state of food items can be compared to the processing logic. The agents of change (fire, heat, or cooling) that change the state of the food items can be compared to Java operators. You need these agents of change so that you can process the raw food items to create delicacies.

In the OCA Java SE 8 Programmer I exam, you’ll be asked questions on the various data types in Java, such as how to create and initialize them and what their similarities and differences are. The exam will also question you on using the Java operators. This chapter covers the following:

  • Primitive data types in Java
  • Literal values of primitive Java data types
  • Object reference variables in Java
  • Valid and invalid identifiers
  • Usage of Java operators
  • Modification of default operator precedence via parentheses
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.53.93