package net.dharmaraj;
public class Base {
int array[];
private void test() {
System.out.println("Value is: " + array[0]);
}
static public void main(String[] a) {
new Base().test();
}
}
What will be the output when you compile and execute the following program.
Select most appropriate answer.
a) Compile time error. Variable array may not have been initialized.
b) Runtime error. Variable array[0] may not have been initialized.
c) Runtime error. java.lang.NullPointerException at line No 6
Ans :- C
OutPut :-
Exception in thread "main" java.lang.NullPointerException
at net.dharmaraj.Base.test(Base.java:7)
at net.dharmaraj.Base.main(Base.java:11)
No comments:
Post a Comment