Variables and primitive data types

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:59 AM on 8/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

24 Terms

1
New cards

What is a key difference between Python and Java regarding basic data types?

In Python, basic data types are objects, where in Java data types are primitive types rather than objects.

2
New cards

Why does Java use primitive data types?

Operations on primitive data types are fast.

3
New cards

What are Java's basic data types called?

Primitive types.

4
New cards

What must happen before a Java variable is used?

It must be declared.

5
New cards

What does a variable declaration tell the compiler?

What type of data will be stored in the variable.

6
New cards

What is the general form of a variable declaration?

type varaiableName;

7
New cards

How are multiple variables of the same type separated in a declaration?

By commas.

8
New cards

What symbol terminates a variable declaration?

A semi colon.

9
New cards

Where are variables typically declared?

Just before they are used or at the beginning of a block.

10
New cards

Can a value of any type be assigned to a variable of any other type?

No, generally a value must be compatible with the variables type.

11
New cards

What is the Java primitive numeric compatibility order?

byte → short → int → long → float → double

12
New cards

What happens to the range of allowed values as you move from left to right in the compatibility list?

It becomes larger.

13
New cards

What is required when assigning a value to a type appearing to the left of its current type in the compatibility list?

An explicit type cast.

14
New cards

What happens when at least one operand in a division is floating-point?

The result is a floating point.

15
New cards

What happens when both operands of a division are integers?

The result is an integer.

16
New cards

How can you ensure that the fractional portion of a division is preserved?

Make at least one operand a floating point value.

17
New cards

What is a type cast?

It takes a value of one type and produces a value of another type with an equivalent value.

18
New cards

What is the syntax for explicitly casting a value?

(desiredType)value

19
New cards

Where does the desired type appear in a type cast?

Inside parentheses immediately before the value or variable being cast.

20
New cards

What happens when a floating-point value is explicitly cast to an integer?

Its fractional portion is truncated.

21
New cards

What is type coercion?

An automatic type conversion performed by Java.

22
New cards

What happens with a prefix operator when it is part of an expression?

The variable is changed first, and the changed value is then used.

23
New cards

What happens with a postfix operator when it is part of an expression?

The original value is used first and then the variable is changed.

24
New cards