Question: QUESTION 3 Analyze the following code. public class Test public static void main ( String [ ] args ) { int [ ] x =

QUESTION 3 Analyze the following code. public class Test public static void main(String[] args){ int[] x = new int [3]; System.out.println("x[0]19"+ x[0]); 1 The program has a runtime error because the array elements are not initialized. The program has a compile error because the size of the array wasn't specified when declaring the array. The program has a runtime error because the array element x[0] is not defined. The program runs fine and displays x[O) is 0. QUESTION 4 Don't worry about what this class does. We're asking about Java language elements. Select the members of this class 01: public class StrCharCounter 02:{03: 04 private ArrayList store = new ArrayListo 05: private int size =0; 06: 07. public boolean add(String sToAdd)08: 09: size++; 10: if (Istore.contains(sToAdd))11: return store.add(sToAdd): 12: else 13: return false; 14: 15: 16: public int calcTotalLength()17: 18: intcnt -0,19: for (int i =0; i < size; i++)20: {21: cnt += store.get(i).length(); 22: 23: return cnt: 24:>25:) StrCharCounter O store O size O add calcTotalLength O cnt This class has no members

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!