QUE.1 What is the output of this program ?
Explanation: Here, ‘A’ and ‘B’ are not strings they are characters. ‘A’ and ‘B’ will not concatenate. The ASCII of the ‘A’ and ‘B’ will be added. The value of ‘A’ is 65 and ‘B’ is 66. Hence Output will be 131.
QUE.2 What is the output of this program?
Answer : a
Explanation: If you try to concatenate any different types of data like integer, character, float with string value, the result will be a string. So ‘A’ will be concatenated with “AB” and answer will be “ABA”.
QUE. 3 What is the output of this program ?
Answer : c
Explanation : Similar data types are added and then converted to string. 20 and 1.34f will be added and then 21.34 will be concatenated with “A” and “B”, hence output will be 21.34AB.
QUE.4 What is the output?
c) [C@19e0bfd (Memory Address)
Explanation : [C@19e0bfd (Memory Address) : str is a character array, if you try to print str.toString() it will not converted to string because str is an object of character array that will print an address in string format.
QUE.5 what is output of this program?
b) Hello Guys!
d) Compile with a Warning
Answer : a
Explanation : System.out.print() does not print new line after printing string, while System.out.println(); prints new line after printing string. Hence output will be HelloGuys! and then new line.
This article is contributed by Ajay Puri. .If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.