Home Subjects Java Programming

Java Programming

Java OOP, collections, multithreading

212 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 211–212 of 212
Topics in Java Programming
Q.211 Hard Basics & Syntax
What will be printed? System.out.println(10 + 20 + "Java");
A 30Java
B 10 + 20 + Java
C 1020Java
D Compilation error
Correct Answer:  A. 30Java
EXPLANATION

String concatenation works left to right. 10 + 20 = 30 (integer addition), then 30 + "Java" = "30Java" (string concatenation).

Test
Q.212 Hard Basics & Syntax
Consider the code: int a = 5; int b = a++; System.out.println(a + " " + b); What is the output?
A 5 5
B 6 5
C 5 6
D 6 6
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

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips