← Quiz: Immutability and Value Objects: all 10 questions
Quiz: Immutability and Value Objects · Question 1 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
String s = "java";
s.toUpperCase();
s.concat("!");
System.out.println(s);
}
}
- A.JAVA!
- B.JAVA
- C.java
- D.java!
Answer & explanation
Correct answer: java
Strings are immutable; both results were thrown away, so s is unchanged.
Can you get the rest right without peeking?
Take the timed Quiz: Immutability and Value Objects quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →