Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
Given:
Person.java
public class Person { String name; public Person(String name) { this.name = name; } public boolean equals(Person person) { return name.equals(person.name); } }
Main.java
public class Main { public static void main(String[] args) { Person person1 = new Person("karel"); Person person2 = new Person("karel"); } }
What is the value of the expression:
person1 == person2
true
false
null
Compile error
Runtime error