CSC 142 Review β€” Classes & Objects

Interactive self-check for CSC 240 Β· answer each question for instant feedback & an explanation

Welcome back! Feeling rusty after the summer is completely normal, and reaching out early is exactly the right move. This quiz walks through the classes & objects foundations that CSC 240 builds on.

There is no grade and no time limit β€” pick an answer to see whether it's right and why. At the end you'll get a per-topic breakdown showing exactly what to review. Take it as many times as you like.

πŸ“Œ Quick reference (open anytime β€” a 1-minute refresher)
Class vs. objectA class is a blueprint (defines fields + methods). An object is one concrete instance made with new. Many objects, one class.
Field / instance variableData that belongs to each object (its state). Usually private.
MethodBehavior β€” code that runs on an object.
Encapsulation / data hidingKeep fields private; expose public methods so outside code can't corrupt the state.
ConstructorSpecial method with the class's name and no return type; initializes a new object. If you write none, Java gives a default no-arg one.
thisRefers to the current object β€” e.g. this.name = name; tells the field apart from the parameter.
Accessor / mutatorGetter returns a field (getX()); setter changes it (setX(...)), often with validation.
static vs. instancestatic belongs to the class (shared, no object needed: Math.pow()). instance members belong to each object.
ReferencesAn object variable holds a reference (an arrow), not the object itself. b = a makes both point to the same object.
== vs .equals()== asks "same object?" (reference). .equals() asks "same contents?" β€” if the class overrides it. Use .equals() for objects.
null / NPEnull = points to no object. Calling a method on null β†’ NullPointerException.
toString()Returns a String describing the object; override it for readable output.
0 / 0 answered
Score: 0

Nice work!

  ← CSC 240 course page