Java OCA OCP Practice Question 3210

Question

Which of the following is a correct override for extending the ListResourceBundle class?

A)  public HashMap < String, String >  getContents() {
            Map < String, String > contents = new HashMap<>();
            contents.add("MovieName", "Avatar");
            return contents;
    }/*from www . jav a 2s . c  o m*/
B)  public Object[] getContents() {
            return new Object[] { { "MovieName" } , { "Avatar" } };
    }

C)  public Object[][] getContents() {
            return new Object[][] { { "MovieName", "Avatar" } };
    }
D)  public String[] getKeysAndValues() {
            return new String[] { { "MovieName" } , { "Avatar" } };
    }

E)  public String[] getProperties() {
          return new String[] { { "MovieName" }, { "Avatar" }}; 
    }
               }


C)

Note

The return type of the getContents() method is Object[][].

Further, the method should return a new object of type Object [][].

So C) is the correct answer.




PreviousNext

Related