37. Given the following code for the Demo class
public class Demo
{
private String[] userNames;
public Demo()
{
userNames = new String[10];
}
public void setName( String s, int n )
{
userNames[n] = s;
}
public void showName( int n )
{
System.out.println( "Name is " +
userNames[n]);
}
public String getName( int n )
{
return userNames[n];
}
}
What would be the result of calling the showName
method with a parameter of 2 immediately after
creating an instance of Demo?
Select 1 correct answer:
A. Standard output would show "Name is null".
B. A NullPointerException would be thrown.
C. An ArrayIndexOutOfBoundsException would be thrown.
D. Standard output would show "Name is ".