Advertisements
Advertisements
Question
Give reason whether the following assignment is correct or not.
String str = 'Computer';
Answer in Brief
Solution
This assignment is incorrect because the string literal Computer has been enclosed in single quotes. It should be written in double quotes. The correct assignment will be String str = "Computer".
shaalaa.com
Is there an error in this question or solution?
Chapter 1.03: Values and Data Types - EXERCISES [Page 33]