Skip to content
Adaptive

Learn Java Primitive Types and Objects

Read the notes, then try the practice. It adapts as you go.When you're ready.

Session Length

~20 min

Adaptive Checks

18 questions

Transfer Probes

9

Lesson Notes

Java is a statically typed, object-oriented programming language used in AP Computer Science A. Understanding primitive data types and objects forms the foundation of all Java programming. Java provides eight primitive types: int, double, boolean, char, byte, short, long, and float.

Objects are accessed through reference variables that store memory addresses. The String class provides methods for text manipulation. Primitives copy values while references copy addresses.

Type casting includes widening (automatic, int to double) and narrowing (explicit cast, double to int). The Math class provides static methods, and wrapper classes enable autoboxing.

You'll be able to:

  • Identify and use Java primitive data types for declarations and arithmetic
  • Apply String methods: length(), substring(), indexOf(), equals()
  • Evaluate type casting, integer division, and modulus expressions
  • Distinguish primitive value assignment from reference behavior

One step at a time.

Interactive Exploration

Adjust the controls and watch the concepts respond in real time.

Key Concepts

Primitive Data Types

Eight types: int (32-bit), double (64-bit float), boolean (true/false), char (16-bit Unicode), byte, short, long, float. Store values directly in memory.

Example: int score=95; double gpa=3.85; boolean pass=true;

Reference Types and Objects

Store memory addresses pointing to heap objects. Can hold null. Assignment copies the reference, not the object.

Example: String name="Alice"; String copy=name; // same object

The String Class

Immutable character sequence. Methods: length(), substring(), indexOf(), equals(), compareTo(). Modification returns new Strings.

Example: "Hello".length() returns 5. "Hello".substring(1,3) returns "el".

Type Casting

Widening (int to double) is automatic. Narrowing (double to int) requires explicit cast and truncates.

Example: double y=7; // widening. int b=(int)9.8; // 9

The Math Class

Static methods: abs(), pow(), sqrt(), random()[0.0,1.0), min(), max().

Example: int die=(int)(Math.random()*6)+1; // 1-6

Integer Division and Modulus

Both int operands: truncates decimal. Modulus (%) returns remainder.

Example: 7/2=3; 7%2=1; 7.0/2=3.5

Autoboxing and Unboxing

Auto-conversion between primitives and wrappers (int/Integer). Enables primitives in ArrayList.

Example: Integer w=42; int u=w;

Explore your way

Choose a different way to engage with this topic β€” no grading, just richer thinking.

Explore your way β€” choose one:

Explore with AI β†’

Concept Map

See how the key ideas connect. Nodes color in as you practice.

Worked Example

Walk through a solved problem step-by-step. Try predicting each step before revealing it.

Adaptive Practice

This is guided practice, not just a quiz. Hints and pacing adjust in real time.

Small steps add up.

What you get while practicing:

  • Math Lens cues for what to look for and what to ignore.
  • Progressive hints (direction, rule, then apply).
  • Targeted feedback when a common misconception appears.

Teach It Back

The best way to know if you understand something: explain it in your own words.

Keep Practicing

More ways to strengthen what you just learned.

Java Primitive Types and Objects Adaptive Course - Learn with AI Support | PiqCue