Java OCA OCP Practice Question 2973

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 w ww  . java  2  s.  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 [][] from the method body.

hence, option C) is the correct answer.




PreviousNext

Related