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?

A) java.util.Arrays.replace (x, 25) ;
B) java.util.Arrays.insert (x, 25) ; I think This one
C) java.util.Arrays.fill (x, 25) ;
D) java.util.Arrays.setAll (x, 25) ;


2. 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?

A) boolean b = java.util.Arrays.compare (x, y) ;
B) boolean b = java.util.Arrays.equals (x, y) ;
C)boolean b = java.util.Arrays.check (x, y) ; I say this one
D) boolean b = java.util.Arrays.binaryCompare (x, y) ;

3. 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?

A) java.util.Arrays.sort (x, y) ;
B) java.util.Arrays.binarySort (x, y) ; This one?
C. java.util.Arrays.order (x, y) ;
D.java.util.Arrays.reorder (x, y) ;

4. 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?

A) int loc = java.util.Arrays.search (x, 7) ;
B) int loc = java.util.Arrays.binarySearch (x, 7) ;
C) int loc = java.util.Arrays.find (x, 7) ; This one
D) int loc = java.util.Arrays.locate (x, 7) ;





Please let me know if my answers are right or wrong and why!
Thank you so much!!

Answer :

FractalX
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

Other Questions