What is the output of the following program?
1: public class Main { 2: private String myStringValue; 3: private boolean myBooleanValue; 4: public static void main(String[] args) { 5: Main wb = new Main(); 6: System.out.print("myBooleanValue = " + wb.myBooleanValue); 7: System.out.print(", myStringValue = " + wb.myStringValue); 8: } 9: }
D.
Boolean fields initialize to false and references initialize to null, so myBooleanValue is false and myStringValue is null.
public class Main { private String myStringValue; private boolean myBooleanValue; public static void main(String[] args) { Main wb = new Main(); System.out.print("myBooleanValue = " + wb.myBooleanValue); System.out.print(", myStringValue = " + wb.myStringValue); } }