zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

What is an 'int'?

A primitive data type that stores whole numbers.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What is an 'int'?

A primitive data type that stores whole numbers.

What is a 'double'?

A primitive data type that stores decimal numbers with high precision.

What is a 'boolean'?

A primitive data type that stores a truth value: either 'true' or 'false'.

What is a 'variable'?

A named storage location in memory that holds a value.

What is 'scope' in Java?

The region of the program where a variable is accessible.

What is 'initialization'?

Giving a variable its first value.

What is 'Integer Overflow'?

When an integer exceeds its maximum or minimum allowed value, wrapping around to the other end.

What does 'strongly typed' mean?

Once a variable has a data type, it cannot be changed to a different data type.

What is 'public' access modifier?

Accessible everywhere.

What is 'private' access modifier?

Accessible only within the class.

What are the differences between 'int' and 'double'?

int: Stores whole numbers | double: Stores decimal numbers with higher precision.

What are the differences between 'public' and 'private' access modifiers?

Public: Accessible everywhere. | Private: Accessible only within the class.

Identify the error in the following code: int x = 3.14;

Cannot assign a 'double' value (3.14) to an 'int' variable.

Identify the error in the following code: boolean flag = 1;

Cannot assign an integer value (1) to a 'boolean' variable. 'boolean' can only be 'true' or 'false'.

Identify the error in the following code: double result = 10 / 3;

Integer division is performed (10/3 = 3), then the result is converted to a double (3.0). To get a double result, one of the operands must be a double (e.g., 10.0 / 3).

What does the following code output? int max = Integer.MAX_VALUE; System.out.println(max + 1);

Integer.MIN_VALUE (due to integer overflow)

Identify the error in the following code: private int 2variable = 10;

Variable names cannot start with a number.

Identify the error in the following code: int public = 5;

'public' is a reserved keyword and cannot be used as a variable name.

What does the following code output? double num = 5.0 / 2; System.out.println(num);

2.5

What does the following code output? boolean isTrue = (5 > 3); System.out.println(isTrue);

true

Identify the error in the following code: Int age = 20;

Java is case-sensitive. 'Int' should be 'int'.

What does the following code output? int a = 5; int b = a + 2; System.out.println(b);

7