
Fundamentals of Data Types and Collections

Quiz
•
Computers
•
11th Grade
•
Medium
Sugeng Riyanto
Used 3+ times
FREE Resource
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.
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Computer Science - Python

Quiz
•
9th - 12th Grade
10 questions
Grade 11 - Quiz 1 Introduction to Arrays

Quiz
•
11th Grade
15 questions
2D Arrays

Quiz
•
9th - 12th Grade
10 questions
Quiz 15 - Array Basics

Quiz
•
11th Grade
20 questions
Java 2 Quiz 9

Quiz
•
10th - 12th Grade
20 questions
Unit 6 ArrayLists and String Methods

Quiz
•
9th - 12th Grade
20 questions
APCSA Arrays

Quiz
•
9th - 12th Grade
15 questions
CPM9.1-9.3 Quiz Review

Quiz
•
9th - 12th Grade
Popular Resources on Wayground
15 questions
Hersheys' Travels Quiz (AM)

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
30 questions
Lufkin Road Middle School Student Handbook & Policies Assessment

Quiz
•
7th Grade
20 questions
Multiplication Facts

Quiz
•
3rd Grade
17 questions
MIXED Factoring Review

Quiz
•
KG - University
10 questions
Laws of Exponents

Quiz
•
9th Grade
10 questions
Characterization

Quiz
•
3rd - 7th Grade
10 questions
Multiply Fractions

Quiz
•
6th Grade