AP Computer Science A primitive types review

Review the key primitive types in AP Computer Science A with essential definitions, comparisons, and quiz questions.

ZoeSparrow87·15 fiches·10 questions·1 vues
APcomputer_scienceprogramming
0
Je sais
1 / 15
0
J'apprends
Recto

What are primitive types?

Appuyez pour retourner
Verso

Basic data types like int, double, char, and boolean used in Java.

Appuyez pour retourner
Je sais
J'apprends

Quiz(10 questions)

Question 1 sur 10

1. Which of the following is NOT a primitive type in Java?

Termes dans ce set(15)

What are primitive types?

Basic data types like int, double, char, and boolean used in Java.

Difference between int and double.

int stores whole numbers; double stores decimal values.

True or false: char can hold multiple characters.

False, because char holds a single character.

What is the range of int in Java?

From -2,147,483,648 to 2,147,483,647.

Fill in the blank: The keyword for floating-point numbers is ____.

double.

What does boolean represent?

It represents true or false values.

Difference between float and double.

float is 32-bit; double is 64-bit, providing more precision.

True or false: The literal '10' is considered a double.

False, because it is an int unless specified with a decimal.

What is the default value of a boolean?

The default value is false.

What is a char's value range?

From '\u0000' (0) to '\uffff' (65,535).

How many bytes does an int consume?

4 bytes.

True or false: An int can hold a decimal value.

False, because an int only holds whole numbers.

Difference between primitive and reference types.

Primitive types hold values directly; reference types hold addresses of objects.

Fill in the blank: An example of a floating-point literal is ____.

3.14.

What type is used for characters?

The char type.

Questions dans ce set(10)

1. Which of the following is NOT a primitive type in Java?

A.int
B.String
C.boolean
D.char

2. What value does a boolean variable default to?

A.true
B.false
C.0
D.null

3. Which primitive type is used for decimal numbers?

A.int
B.double
C.char
D.boolean

4. What is the size of a float in bytes?

A.2
B.4
C.8
D.16

5. True or false: A double can precisely represent all decimal numbers.

A.True
B.False
C.Depends on the range
D.Only certain values

6. Which of these is a character literal?

A.'A'
B."A"
C.A
D.None of the above

7. What is the largest value an int can hold?

A.2,147,483,647
B.1,000,000
C.3.14
D.1,000,000,000

8. Which primitive type has the smallest range?

A.int
B.float
C.byte
D.double

9. What will the expression 5 / 2 return in Java?

A.2
B.2.5
C.2.0
D.3

10. Which primitive type is suitable for true/false logic?

A.int
B.boolean
C.char
D.double

Sets associés

Créez votre propre set d'étude

Téléchargez un PDF, collez vos notes ou décrivez un sujet – l'IA génère des fiches, des quiz et plus en quelques secondes.

Mis en avant sur