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 flashcards·10 vragen·1 weergaven
APcomputer_scienceprogramming
0
Ken ik
1 / 15
0
Aan het leren
Voorkant

What are primitive types?

Tik om om te draaien
Achterkant

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

Tik om om te draaien
Ken ik
Aan het leren

Quiz(10 vragen)

Vraag 1 van 10

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

Termen in deze 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.

Vragen in deze 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

Gerelateerde sets

Maak je eigen studieset

Upload een PDF, plak je notities of beschrijf een onderwerp – AI genereert flashcards, quizzen en meer in seconden.