Questions in java display in my main slide

hi … hello from cancun, and i have one question, i have a code in java and run well in a compiler online of java, but in active presenter, when i put the code in javascript show error and i need to ejecute and then show the trivia answers in the slide, the code show the correct answers i have respond well, and how can generate a variable to show how many correct answer have…

the code in java is this:

public class Countdown {
public static void main(String args) {
int duration = 10; // Duration of the countdown in seconds

    for (int i = duration; i >= 0; i--) {
        System.out.println(i);
        try {
            Thread.sleep(1000); // Pause for 1 second
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    System.out.println("Countdown complete!");
}

}

program questions
generate a trivia game with 10 questions about computer games, with 2 posbile answers and the way to anwers de questions is just usien the numbers 1 for answer one and the key 2 for opcion two and say correct or incorrect in every ramdom question

import java.util.Random;
import java.util.Scanner;

public class TriviaGame {
public static void main(String args) {
String questions = {
“What is the best-selling video game of all time?”,
“Which game is known for its block-building and survival gameplay?”,
“Who is the main character in the ‘Legend of Zelda’ series?”,
“Which game features a plumber named Mario?”,
“What is the highest-grossing media franchise of all time?”,
“Which game is set in a post-apocalyptic wasteland?”,
“Who is the creator of the ‘Minecraft’ game?”,
“Which game is known for its battle royale mode?”,
“What is the name of the protagonist in ‘Assassin’s Creed’ series?”,
“Which game is set in the fantasy world of Azeroth?”
};

    String[][] options = {
        {"Minecraft", "Tetris"},
        {"Fortnite", "Minecraft"},
        {"Link", "Mario"},
        {"Super Mario Bros.", "Sonic the Hedgehog"},
        {"Pokemon", "Mario"},
        {"Fallout", "The Elder Scrolls"},
        {"Notch", "Markus Persson"},
        {"PlayerUnknown's Battlegrounds", "Fortnite"},
        {"Ezio Auditore", "Altair Ibn-La'Ahad"},
        {"World of Warcraft", "Final Fantasy"}
    };

    String[] answers = {
        "2", "1", "1", "1", "1", "2", "1", "2", "1", "1"
    };

    Random random = new Random();
    Scanner scanner = new Scanner(System.in);
    int score = 0;

    System.out.println("Welcome to the Computer Games Trivia Game!");
    System.out.println("Answer the following questions by entering the corresponding number.");
    System.out.println();

    for (int i = 0; i < questions.length; i++) {
        System.out.println("Question " + (i + 1) + ": " + questions[i]);
        System.out.println("1. " + options[i][0]);
        System.out.println("2. " + options[i][1]);
        System.out.print("Enter your answer: ");

        String userAnswer = scanner.nextLine();

        if (userAnswer.equals(answers[i])) {
            System.out.println("Correct!");
            score++;
        } else {
            System.out.println("Incorrect!");
        }

        System.out.println();
    }

    System.out.println("Game Over!");
    System.out.println("Your final score is: " + score + "/" + questions.length);
}

}

Hi @loracancun,

For your information, ActivePresenter supports JavaScript, not Java.
Therefore, in your case, you can refer to the tutorials below to know how to create random quiz in ActivePresenter:

Best regards,
Quynh Anh