Java online IDE & code editor for technical interviews
Running OpenJDK 17 – IntelliSense is enabled
Experience the Java IDE yourself
See just how easy and intuitive CoderPad Interview is to use below.
Guidelines to use Java in this online IDE
You should define a public class named Solution
with a public static void main
. Your code is compiled with -Xlint
(linting) and run with -ea
(assertions enabled).
A few libraries are included for your convenience, and are available on the classpath with no additional work from you. Simply import and they’re available for use:
- json-simple for parsing/encoding JSON.
- guava provides immutable collections and other handy utility classes.
- Apache Commons Lang for assorted utilities. The import prefix is
org.apache.commons.lang3
, so you can perform imports by writingimport org.apache.commons.lang3.ArrayUtils
. - JUnit, the gold standard for testing in Java. If you want to ask your candidate to write JUnit-style tests during the interview, please format your Java code like so (stack traces originating from JUnit errors are trimmed for brevity):
import org.junit.*;
import org.junit.runner.*;
public class Solution {
@Test
public void testNoop() {
Assert.assertTrue(true);
}
public static void main(String[] args) {
JUnitCore.main("Solution");
}
}
Code language: Java (java)
- jMock, a library to assist with mocking in Java. Combining jMock with the previous JUnit example:
import org.jmock.*;
import org.junit.*;
import org.junit.runner.*;
interface Receiver {
void receive(String message);
}
public class Solution {
@Test
public void testMock() {
Mockery context = new Mockery();
Receiver receiver = context.mock(Receiver.class);
context.checking(new Expectations() {{
oneOf (receiver).receive("hello");
}});
receiver.receive("hello");
context.assertIsSatisfied();
}
public static void main(String[] args) {
JUnitCore.main("Solution");
}
}
Code language: Java (java)