Java SE 8 Programmer 1Z0–808 Practice Full Test 1

© examsiri.com
Question : 58 of 84
 
Marks: +1, -0
Given the code format:
public static void main (String [] args) {
  String names [] = {"Thomas", "Peter","Joseph"};
  String pwd [] = new String [3];
  int idx = 0;
  try {
    for (String n: names) {
      pwd [idx] = n.substring (2, 6);
      idx++;
    }
  }
  catch (Exception e) {
    System.out.println("Invalid Name");
  }

  for (String p: pwd) {
    System.out.println (p);
  }
}

What is the result?
Go to Question: