Java Programming
Java OOP, collections, multithreading
Showing 211–212 of 212 questions
What will be printed? System.out.println(10 + 20 + "Java");
Correct Answer:
A. 30Java
EXPLANATION
String concatenation works left to right. 10 + 20 = 30 (integer addition), then 30 + "Java" = "30Java" (string concatenation).
Consider the code: int a = 5; int b = a++; System.out.println(a + " " + b); What is the output?
Correct Answer:
B. 6 5
EXPLANATION
The post-increment operator (a++) returns the value before incrementing. So b = 5, then a becomes 6. Output: 6 5