1.

Which of these exceptions will be thrown if we declare an array with negative size?(a) IllegalArrayException(b) IllegalArraySizeExeption(c) NegativeArrayException(d) NegativeArraySizeExeptionThe question was posed to me in a job interview.Asked question is from Java’s Built in Exceptions topic in portion Exploring java.lang & java.io of Java

Answer»

Right choice is (d) NegativeArraySizeExeption

Easiest EXPLANATION: Array size must always be positive if we declare an array with NEGATIVE size then BUILT in exception “NegativeArraySizeException” is thrown by the java’s RUN TIME system.



Discussion

No Comment Found

Related InterviewSolutions