Bird
0
0

What will be the output of the following code?

medium📝 Predict Output Q13 of 15
Java - Strings and String Handling
What will be the output of the following code?
String first = "Good";
String second = "Morning";
System.out.println(first + " " + second);
AGoodMorning
BGood+Morning
CGood Morning
DgninroM dooG
Step-by-Step Solution
Solution:
  1. Step 1: Understand string concatenation

    The + operator joins strings. Here, first + " " + second adds a space between words.
  2. Step 2: Combine the strings

    "Good" + " " + "Morning" results in "Good Morning" with a space.
  3. Final Answer:

    Good Morning -> Option C
  4. Quick Check:

    + joins strings including spaces [OK]
Quick Trick: Use + with " " to add spaces between words [OK]
Common Mistakes:
  • Forgetting to add space between words
  • Using + without quotes for space
  • Expecting + to print plus sign

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes