Challenge - 5 Problems
Java First Program Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Java program?
Look at this Java program. What will it print when run?
Java
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, Java!"); } }
Attempts:
2 left
💡 Hint
Check the exact text inside the quotes and capitalization.
✗ Incorrect
The program prints exactly what is inside the quotes in System.out.println, including capitalization and punctuation.
🧠 Conceptual
intermediate1:30remaining
What is the role of the main method in a Java program?
In Java, what does the main method do?
Attempts:
2 left
💡 Hint
Think about what happens when you run a Java program.
✗ Incorrect
The main method is where Java starts running the program. Without it, the program won't run.
🔧 Debug
advanced2:00remaining
What error does this Java program produce?
Look at this Java code. What error will it cause when compiled?
Java
public class Test { public static void main(String[] args) { System.out.println("Hello World"); } }
Attempts:
2 left
💡 Hint
Check the end of the System.out.println line.
✗ Incorrect
Java statements must end with a semicolon. This line is missing it, causing a syntax error.
📝 Syntax
advanced1:30remaining
Which option correctly declares the main method in Java?
Choose the correct way to write the main method header in Java.
Attempts:
2 left
💡 Hint
Remember the order and types in the method signature.
✗ Incorrect
The correct order is public static void main(String[] args). Other orders or missing brackets cause errors.
🚀 Application
expert2:00remaining
How many lines will this Java program print?
Consider this Java program. How many lines will it print when run?
Java
public class CountLines { public static void main(String[] args) { for (int i = 0; i < 3; i++) { System.out.println("Line " + i); } } }
Attempts:
2 left
💡 Hint
Count how many times the loop runs.
✗ Incorrect
The loop runs from i=0 to i=2, printing one line each time, so 3 lines total.