Home » Java Programming » Language Fundamentals

Which is a valid declarations of a String?

Correct Answer: String s1 = null;

Explanation:

Option A sets the String reference to null.


Option B is wrong because null cannot be in single quotes.


Option C is wrong because there are multiple characters between the single quotes ('abc').


Option D is wrong because you can't cast a char (primitive) to a String (object).


← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion