Cvent Interview Question

Write an example of a program that would run out of memory.

Interview Answers

Anonymous

Apr 16, 2015

Any infinite loop might do. so for(;;)

3

Anonymous

Feb 24, 2019

public static int[] decode(InputStream in, int len) throws IOException { int result[]; try { result = new int[len]; } catch (OutOfMemoryError e) { throw new IOException("Result too long to read into memory: " + len); } catch (NegativeArraySizeException e) { throw new IOException("Cannot read negative length: " + len); } ... }