Web Analytics

These questions are from Java

  1. if x and y are both arrays of int values which of the following shows a call to a method of the arrays class that will fill all the elements of the array with the value 25?

Ajava.util.Arrays.replace (x, 25) ;
Bjava.util.Arrays.insert (x, 25) ; I think This one
Cjava.util.Arrays.fill (x, 25) ;
Djava.util.Arrays.setAll (x, 25) ;


  1. If x and y are both arrays of int values, which of the following shows a call to a method of the Arrays class that will determine if the two arrays have the same contents?

Aboolean b = java.util.Arrays.compare (x, y) ;
Bboolean b = java.util.Arrays.equals (x, y) ;

C)boolean b = java.util.Arrays.check (x, y) ; I say this one

Dboolean b = java.util.Arrays.binaryCompare (x, y) ;

  1. if x is an array of int values which of the following shows a call to a method of the Arrays class that will sort its contents?

Ajava.util.Arrays.sort (x, y) ;
Bjava.util.Arrays.binarySort (x, y) ; This one?
Cjava.util.Arrays.order (x, y) ;

D.java.util.Arrays.reorder (x, y) ;

  1. If x is a sorted array of int values which of the following shoes a call to a method of the Arrays class that will determine if the value 7 exists in the array?

Aint loc = java.util.Arrays.search (x, 7) ;
Bint loc = java.util.Arrays.binarySearch (x, 7) ;
Cint loc = java.util.Arrays.find (x, 7) ; This one
Dint loc = java.util.Arrays.locate (x, 7) ;





Please let me know if my answers are right or wrong and why!

Thank you so much!!

Verified Answer :

1 C because insert isn't a valid function
2 B because check isn't a valid function
3 A because binarySort isn't a thing (it's binary search)
4 B because find isn't a valid function
And just to let you know, I never knew any of these existed, but what I did is I searched up "java array functions," and skimmed through the documentation for the functions online. If you are a Computer Science/ Software Engineering major, this is something you should know how to do. If you want the website: docs.oracle.com/javase/7/docs/API/java/util/Arrays.html