Java Objects

By Raul Rios

Object variables are called references because they don’t actually store an object but reference it, as opposed to primitive type variables. You create an object from a class (that provides kind of a blueprint for it) using the new operator, which: Instantiates a class, i.e. invokes a class constructor (the ..Continue Reading

Java Literals

By Raul Rios

Basically, a literal is the source code representation of a fixed value. In order to be able to choose the right answer for some exam questions, you must be able to infer the data type of literals that appear in the sample code of those questions: Literal type Description Data type of the ..Continue Reading

Autoboxing and Unboxing

By Raul Rios

The autoboxing and unboxing Java features let you write cleaner and easier-to-read code by allowing you to use either primitive data types or their corresponding wrapper objects. Java then automatically makes the needed conversions in code at runtime. Conversion Applied when Autoboxing Primitive → Wrapper A primitive value is: Passed as ..Continue Reading

Primitive Data Types and Wrapper Classes

By Raul Rios

The following table lists the primitive data types that are available in Java: Type Size (bits) Default value Range byte 8 0 -128 to 127 short 16 0 -32768 to 32767 int 32 0 -2n-1 to 2n-1-1 long 64 0L -2n-1 to 2n-1-1 float 32 0.0f No need to know ..Continue Reading