Java OCA OCP Practice Question 3011

Question

In a class that extends ListResourceBundle, which one of the following method definitions correctly overrides the getContents() method of the base class?

a)  public String[][] getContents() {
        return new Object[][] { { "1", "Uno" }, { "2", "Duo" }, { "3", "Trie" }};
    }//from w  ww . ja  va  2  s .  co m

b)  public Object[][] getContents() {
        return new Object[][] { { "1", "Uno" }, { "2", "Duo" }, { "3", "Trie" }};
    }

c)  private List<String> getContents() {
         return new ArrayList (Arrays.AsList({ { "1", "Uno" }, { "2", "Duo" },
         { "3", "Trie" }});
    }

d)  protected Object[] getContents(){
        return new String[] { "Uno", "Duo", "Trie" };
    }


b)

Note

the getContents() method is declared in ListResourceBundle as follows:

protected abstract Object[][] getContents()

the other three definitions are incorrect overrides and will result in compiler error(s).




PreviousNext

Related