What is the right syntax to read an integer from the user in Java?

PYQ RPSC Programmer 2024

What is the right syntax to read an integer from the user in Java?

  1. A.

    Scanner sc = new Scanner(System.in); int num = sc.readInt();

  2. B.

    Scanner sc = new Scanner(System.in); int num = sc.inputInt();

  3. C.

    Scanner sc = new Scanner(System.in); int num = sc.nextInt();

  4. D.

    Scanner sc = new Scanner(System.in); int num = sc.getInt();

  5. E.

    Question not attempted

Attempted by 285 students.

Sign up free to check your answer

Sign up free

Explore the full course: Rpsc Programmer

Loading lesson…