Language Fundamentals

Q1: Which is a valid declarations of a String?

A String s1 = null;

B String s2 = 'null';

C String s3 = (String) 'abc';

D String s4 = (String) '\ufeed';

ANS:A - String s1 = null;

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).



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.