public class Q1 {
public static void main(String[] args) {
System.out.println("Hello World!");
}}
Hello World!
1. public class Q1 {
2. public static void main(String[] args) {
3. int x = 5
4. System.out.println(x);
5. }}
line 3 (missing semicolon)
101
5
What color are the smurfs?
blue
What formula do you use to find the roots of a function, even if they are imaginary?
Quadratic Formula
public class Q2 {
public static void main(String[] args) {
int a = 5;
int b = 3;
System.out.println(a*a + b);
}}
28
1. public class Q2 {
2. public static void main(String[] args) {
3. String name = "Alice";
4. if(name = "Bob") {
5. System.out.println("Hello Bob");
6. }}}
line 4 (should use ".equals" instead of "=")
1111
15
How many countries are there? within 5
195
What is wrong with the following sentence?
Running down the stairs, the backpack was in Jim's hands as he left his house.
Misplaced Modifier
public class Q3 {
public static void main(String[] args) {
String x = "Java";
String y = "Script";
System.out.println(x + y.length() + "7");
}}
Java67
1. public class Q3 {
2. public static void main(String[] args) {
3. int[] numbers = {1, 2, 3, 4};
4. System.out.println(numbers[4]);
5. }}
Line 4 (there isnt a 4th index in the array)
index out of bounds error
100101
37
What is the only mammal capable of true flight?
Bat
When energy is released in the body, what does ATP break down into?
ADP + Phosphate group
public class Q4 {
public static void main(String[] args) {
int x = 7;
if (x % 2 == 0) {
System.out.println("Yes");
} else {
System.out.println("No");
}}}
No
1. public class Q4 {
2. public static void main(String[] args) {
3. for(int i = 0; i < 5; i++)
4. System.out.println("Number: " + i);
5. }}}}
Line 5 (extra closing "}" bracket)
1101101
109
What is the smallest country in the world by land?
Vatican City
What is the median of this list: [1,1,2,3,3,3,3,3,4,4,4,5,5,5,6,7,7,7,8,8,9,9]
4.5
public class Q5 {
public static void main(String[] args) {
String word = "coast";
for (int i = 0; i < word.length(); i += 2) {
System.out.print(word.charAt(i));
}}}
cat
1. public class Q5 {
2. public static void main(String[] args) {
3. int x = 10;
4. int y = 0;
5. System.out.println(x / y);
6. }}
Line 5 (dividing by 0 when u run it)
101011101
349
What is the atomic symbol of "Cs"?
Caesium
A 1670 kg car is speeding at 40 m/s. It crashes headfirst into a 900 kg car going at 60 m/s. If the two cars stick together as they collide, approximately what is the velocity of the two cars immediately after the crash? (Round to the nearest integer)
47 m/s