Java-1-Ch02-Quiz02

Java-1-Ch02-Quiz02

University

13 Qs

quiz-placeholder

Similar activities

Ergonomi Industri Pertemuan 11

Ergonomi Industri Pertemuan 11

University

14 Qs

ADD-ON Course 1st test

ADD-ON Course 1st test

University

10 Qs

EL_QUIZ

EL_QUIZ

University

15 Qs

Scopri il Tostapane

Scopri il Tostapane

5th Grade - University

10 Qs

Honeypots

Honeypots

University

10 Qs

Python Programming Basics

Python Programming Basics

University

14 Qs

Quiz for subtopic UPS II [2.4 - 2.6]

Quiz for subtopic UPS II [2.4 - 2.6]

University

15 Qs

Java-1-Ch02-Quiz02

Java-1-Ch02-Quiz02

Assessment

Quiz

Science

University

Hard

Created by

Sreng Vichet

Used 6+ times

FREE Resource

13 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which package do you need to import to use the Scanner class in Java?

A. java.util.Scanner

B. java.io.Scanner

C. java.net.Scanner

D. java.lang.Scanner

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the main purpose of the Scanner class in Java?

A. To create GUI components.

B. To read input from various input sources.

C. To execute SQL queries.

D. To perform mathematical operations.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method of the Scanner class is used to read a string input from the user?

A. nextString()

B. next()

C. readString()

D. nextLine()

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If you want to read an integer input from the user using the Scanner class, which method would you use?

A. nextInt()

B. next()

C. nextInteger()

D. nextNumber()

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will happen if the user enters a non-numeric value while using nextInt()?

A. It will return 0.

B. It will throw a NumberFormatException.

C. It will throw an InputMismatchException.

D. It will return null.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create a Scanner object to read from the keyboard?

A. Scanner scanner = new Scanner(System.in);

B. Scanner scanner = new Scanner(System.out);

C. Scanner scanner = new Scanner(System.err);

D. Scanner scanner = new Scanner(System.console());

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following methods reads a floating-point number from the input?

A. nextInt()

B. nextFloat()

C. nextDouble()

D. Both B and C

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?