Cumulative Project 4 - Game Logic Part II

The exercise of the project is : https://www.codecademy.com/paths/introduction-to-android-with-java/tracks/java-arrays-and-loops/modules/cumulative-project-4/projects/unquote-game-logic-pt-ii

Hello everyone, I am learning java. Inside the onAnswerSubmission() function I cannot understand how the variable currentQuestion saves the object returned by the getCurrentQuestion() function. And then, I cannot understand how isCorrect() function takes the information to validate.
Thank you in advance :grinning:

Here is my code in MainActivity.java and Question.java

//MainActivity.java
public class MainActivity {

    // TODO #1: add integer member variables here
int currentQuestionIndex;
int totalCorrect;
int totalQuestions; 

    // TODO #2: add ArrayList member variable here
ArrayList<Question> questions = new ArrayList<Question>();

    // TODO #3 add startNewGame() here    
public void startNewGame(){
  questions = new ArrayList<Question>();
 Question question_1 = new Question(268514,"How long have not been working?","Six months","Three months","Eighteen months","Twelve months",2);
 Question question_2 = new Question(314903,"When is my birthday?","August 19","Abril 3","December 11","July 28",0); 
 Question question_3 = new Question(631755,"How long has your relationship been longest?","12 months","3 months","10 days","40 months",3);
totalCorrect = 0;
totalQuestions = 0;
questions.add(question_1);
questions.add(question_2);
questions.add(question_3);
Question firstQuestion = chooseNewQuestion();
// displayQuestion(firstQuestion);
}

    int generateRandomNumber(int max) {
      double randomNumber = Math.random();
      double result = max * randomNumber;
      return (int) result;
    }

    // TODO #4 add chooseNewQuestion() here
public Question chooseNewQuestion(){
int n = questions.size();
int randomNumber = generateRandomNumber(n-1);
currentQuestionIndex = randomNumber;
return questions.get(currentQuestionIndex);
}
    // TODO #5 add getCurrentQuestion() here
public Question getCurrentQuestion(){
  return questions.get(currentQuestionIndex);
}
    // TODO #6 add onAnswerSubmission() here
public void onAnswerSubmission(){
  Question currentQuestion = getCurrentQuestion();
  if(currentQuestion.isCorrect()){
    totalCorrect += 1;
  }
  questions.remove(currentQuestion);
  if (questions.size()==0){
    System.out.println("Game over");
    startNewGame();
  }else{
  chooseNewQuestion();
}
}


//Question.java
public class Question(){
public class Question {
    int imageId;
    String questionText;
    String answer0;
    String answer1;
    String answer2;
    String answer3;
    int correctAnswer;
    int playerAnswer;

    public Question(int imageIdentifier,
      String questionString,
      String answerZero,
      String answerOne,
      String answerTwo,
      String answerThree,
      int correctAnswerIndex) {
        
        imageId = imageIdentifier;
        questionText = questionString;
        answer0 = answerZero;
        answer1 = answerOne;
        answer2 = answerTwo;
        answer3 = answerThree;
        correctAnswer = correctAnswerIndex;
        playerAnswer = -1;
    }

    boolean isCorrect() {
      return correctAnswer == playerAnswer;
    }
}