Java is a popular programming language. What is its main use?
Think about where you see Java programs running, like apps or websites.
Java is widely used to build mobile apps (especially Android), web applications, and large software systems because it is versatile and runs on many devices.
Look at this Java program and choose the output it produces when run.
public class Main { public static void main(String[] args) { int x = 5; int y = 10; System.out.println("Sum is: " + (x + y)); } }
Remember that parentheses change how expressions are calculated in Java.
The parentheses around (x + y) make Java add the numbers first, then convert to string. So it prints "Sum is: 15".
Analyze the code and select the exact output it produces.
public class Main { public static void main(String[] args) { String s = "Java"; s += 123; System.out.println(s); } }
In Java, adding a number to a string converts the number to text.
Using += with a string and a number converts the number to string and joins them. So "Java" + 123 becomes "Java123".
Look at this Java code and choose the error it produces when compiled.
public class Main { public static void main(String[] args) { int number = "100"; System.out.println(number); } }
Check the type of the value assigned to an int variable.
You cannot assign a text (String) value to an int variable directly. This causes a type mismatch error.
Java is called platform-independent. What feature allows this?
Think about how Java runs the same program on different computers without changes.
Java compiles code into bytecode, which the JVM interprets on any device, making it platform-independent.