0

String s=null; s=s+"hello"; system.out.println("s");

what will be the output? Nullpointer or print value ?? Answer plz..

15th Aug 2017, 4:21 PM
narendra kumar
narendra kumar - avatar
16 odpowiedzi
+ 1
The real output is error. "system" must have a capital 'S'. Aside from that, the output is s. I assume based on the past comments you actually editted the question, and didn't have the quotes there before. Without the quotes, nullhello would be printed. The reason for this is because it is written in the Source Code to use the value "null" if the string itself is null. So, you won't be getting any null exceptions for printing things.
15th Aug 2017, 9:40 PM
Rrestoring faith
Rrestoring faith - avatar
0
nullhello
15th Aug 2017, 4:50 PM
narendra kumar
narendra kumar - avatar
0
right
15th Aug 2017, 4:55 PM
corejava
0
andar will be nullhello
15th Aug 2017, 4:59 PM
narendra kumar
narendra kumar - avatar
0
if u give null to string it prints nullhello
15th Aug 2017, 4:59 PM
corejava
0
don't give \0 give us null then see output it prints nullhello
15th Aug 2017, 5:00 PM
corejava
0
no don't give double quotes just give null alone
15th Aug 2017, 5:04 PM
corejava
0
yes null not in double quotes
15th Aug 2017, 5:06 PM
narendra kumar
narendra kumar - avatar
0
nullhello, but if you remove the quotes. System.out.println("s"); // Gives a String: "s"
15th Aug 2017, 6:15 PM
Boris Batinkov
Boris Batinkov - avatar
0
thankuuu
16th Aug 2017, 2:16 AM
narendra kumar
narendra kumar - avatar
- 1
see the out put here '\0' means null in python https://code.sololearn.com/cTxS8NWYHx0p/?ref=app
15th Aug 2017, 4:44 PM
sayan chandra
sayan chandra - avatar
- 1
hello will be printed
15th Aug 2017, 4:45 PM
sayan chandra
sayan chandra - avatar
- 1
onlyyyy hello
15th Aug 2017, 4:58 PM
sayan chandra
sayan chandra - avatar
- 1
null is a special type of non charecter... that consumes no space
15th Aug 2017, 4:59 PM
sayan chandra
sayan chandra - avatar
- 1
s=null means s is a empty string s="null" means s is a string which prints thw word null null is a keyword when not in inverted commas
15th Aug 2017, 5:03 PM
sayan chandra
sayan chandra - avatar
- 1
in java...its null the keyword in python or in c it is '\0' '\0' = null
15th Aug 2017, 5:16 PM
sayan chandra
sayan chandra - avatar