Can some please help me to solve this problem. when I try to print getCorrectAnswer it is printing null. how can I getCorrectAnswer to print the correctAnswer thanks.
public class Test1 {
private String correctAnswer;
public String getCorrectAnswer() {
return correctAnswer;
}
public void setUpCorrectAnswer() {
if (1 == 1) {
correctAnswer = "a";
} else {
correctAnswer = "d";
}
}
public static void main(String[] args) {
Test1 a = new Test1();
System.out.println(" Answer " + a.getCorrectAnswer());
}
}