Search Header Logo

Fundamentals of Data Types and Collections

Authored by Sugeng Riyanto

Computers

11th Grade

Used 3+ times

Fundamentals of Data Types and Collections
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primitive data type used for whole numbers?

float

integer

string

boolean

Answer explanation

The primitive data type used for whole numbers is 'integer'. Unlike 'float', which represents decimal numbers, 'integer' specifically denotes whole numbers without any fractional component.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which data type is used to represent decimal numbers?

string

boolean

integer

float

Answer explanation

The correct data type for representing decimal numbers is 'float'. Unlike integers, which are whole numbers, floats can store numbers with fractional parts, making them suitable for precise calculations involving decimals.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What character is used to denote a single character in Java?

#

"

' '

'

Answer explanation

In Java, a single character is denoted by single quotes, like 'a'. This distinguishes it from double quotes, which are used for strings. Therefore, the correct answer is the character '.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you concatenate two strings in Java?

You can concatenate two strings in Java using the '+' operator or the String.concat() method.

You can concatenate two strings using the '&' operator.

Strings can only be concatenated using the StringBuilder class.

You must use the String.join() method to concatenate strings.

Answer explanation

In Java, you can concatenate two strings using the '+' operator or the String.concat() method. The other options provided are incorrect as they do not represent valid methods for string concatenation in Java.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the default value of an int variable in Java?

0

null

1

-1

Answer explanation

In Java, the default value of an int variable is 0. This means that if an int variable is declared but not initialized, it will automatically be set to 0.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of an ArrayList in Java?

An ArrayList is a fixed-size array that cannot change its length.

An ArrayList is primarily used for storing key-value pairs.

The purpose of an ArrayList in Java is to provide a dynamic array that can grow and shrink in size as needed.

An ArrayList is used to store only primitive data types.

Answer explanation

The correct choice highlights that an ArrayList in Java is a dynamic array, allowing it to grow and shrink in size as needed, unlike fixed-size arrays. This flexibility makes ArrayLists suitable for various data storage needs.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you add an element to an ArrayList?

Use the 'append' method, e.g., arrayList.append(element);

Assign the element directly, e.g., arrayList[index] = element;

Use the 'add' method, e.g., arrayList.add(element);

Use the 'insert' method, e.g., arrayList.insert(index, element);

Answer explanation

To add an element to an ArrayList, you should use the 'add' method, as in arrayList.add(element). This method correctly appends the element to the end of the list, unlike the other options which are incorrect.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?