Challenge - 5 Problems
Heap Memory Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate2:00remaining
What is the output of this Java code related to heap memory?
Consider the following Java code snippet. What will be printed to the console?
Java
public class HeapTest { public static void main(String[] args) { String a = new String("hello"); String b = new String("hello"); System.out.println(a == b); System.out.println(a.equals(b)); } }
Attempts:
2 left
🧠 conceptual
intermediate1:30remaining
Which statement about Java heap memory is true?
Choose the correct statement about Java heap memory.
Attempts:
2 left
🔧 debug
advanced2:00remaining
What error does this code cause related to heap memory?
Analyze the following Java code. What error will it cause when run?
Java
public class HeapOverflow { public static void main(String[] args) { int i = 0; while(true) { i++; int[] arr = new int[1000000]; System.out.println("Iteration: " + i); } } }
Attempts:
2 left
📝 syntax
advanced1:30remaining
Which option correctly declares an object stored in heap memory?
Which of the following Java code snippets correctly creates an object that will be stored in heap memory?
Attempts:
2 left
🚀 application
expert2:30remaining
How many objects are created in heap memory after running this code?
Consider this Java code snippet. How many distinct objects are created in heap memory after it runs?
Java
public class ObjectCount { public static void main(String[] args) { String s1 = "test"; String s2 = new String("test"); String s3 = s2.intern(); Integer i1 = 100; Integer i2 = new Integer(100); } }
Attempts:
2 left
