Ask Question
3 January, 01:27

Consider the following code snippet in Java 6 or later: String[] data = { "abc", "def", "ghi", "jkl" }; String[] data2 = Arrays. copyOf (data, data. length - 1); What does the last element of data2 contain?

+4
Answers (1)
  1. 3 January, 04:04
    0
    The last element of data2 is ghi.

    Explanation:

    In this code Arrays. copyOf () function copies the data of string data array into string data2 array by length-1. Here string data array has 4 element in it but according to code i. e Arrays. copyOf (data, data. length - 1); string data2 will contains only 3 element.

    So the last element is "ghi", second last element is "def" and first element is "abc: in data2 array.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following code snippet in Java 6 or later: String[] data = { "abc", "def", "ghi", "jkl" }; String[] data2 = Arrays. copyOf ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers