Computer Programming (COPROG) Practice Test

Access More Questions
Which of the following is true about String in Java?
Correct Answer:
It is a class in java.lang and a non-primitive type
Explanation:
Strings in Java are reference types, not primitive values. They are implemented as objects of the String class, which lives in the java.lang package. Because it’s a class, String is a non-primitive type. Strings are immutable: once a String object is created, its character sequence cannot be changed, and operations like concatenation create new String objects. That combination—being a class in java.lang and a non-primitive type—is why this statement is correct. Other options miss or misframe the reality: primitive types are not objects and don’t have methods; string literals aren’t about being created by default in any special sense; and while Strings are immutable, that property comes from the class design, not from being primitive.

Access more questions from this quiz

Continue to Computer Programming (COPROG) Practice Test for more practice questions and the full quiz experience.

Access More Questions