ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!


    Question

    Consider the following Java code: import

    java.util.Arrays; public class Splitter { ┬а ┬а public static void main(String[] args) { ┬а ┬а ┬а ┬а String data = "item1::value1::item2::value2"; ┬а ┬а ┬а ┬а String[] parts = data.split("::"); ┬а ┬а ┬а ┬а System.out.println(parts.length + " " + parts[1]); ┬а ┬а } } What will be the output of this program?
    A 4 value1 Correct Answer Incorrect Answer
    B 2 value1 Correct Answer Incorrect Answer
    C 4 item1 Correct Answer Incorrect Answer
    D 2 item2 Correct Answer Incorrect Answer
    E Compile-time error Correct Answer Incorrect Answer

    Solution

    Correct Answer: A (The string is split by "::". The parts are "item1", "value1", "item2", "value2". So parts.length is 4. parts[1] is "value1".)

    Practice Next
    More IT Operating System Questions
    ask-question