Lesson 22 of 34 · Classes & Objects
Quiz: Java Classes and Objects
You can now design your own Java types: classes with fields and constructors, encapsulated state behind getters and validating methods, static members that belong to the class itself, and objects that print, compare and hash correctly. Check that the key ideas stuck before you face the chapter boss.
What this quiz covers
The questions check what you learned in the Classes & Objects chapter of Learn Java. Not sure about a topic? Review its lesson first:
- Java Classes and Objects: Constructors and new
Learn Java classes and objects: fields, constructors, the new keyword, this and instance methods. Build a Hero class and test it in your browser.
- Java Encapsulation: private Fields, Getters and Setters
Protect your Java objects with encapsulation: private fields, getters, setters with validation and final fields. Build a safe BankAccount class.
- Java static vs Instance Members
Understand the Java static keyword: shared static fields, static methods, static final constants and how they differ from instance fields and methods.
- Java toString(), equals() and hashCode()
Override toString(), equals() and hashCode() in Java the right way, learn == vs equals, why HashSet needs hashCode and how records generate all three.
Keep learning
Need a quick reminder? The Java cheat sheet has every topic of Learn Java on one page.
Lesson last updated on .