Topic 2: Variables, Data Types and Operators

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

Q: What is a variable in Java?

A variable is a container that holds data that can be changed during program execution.

2
New cards

Q: What are the types of variables in Java?

Local variables, instance variables (non-static fields), and class variables (static fields).

3
New cards

Q: What is a data type?

A data type defines the kind of value a variable can hold, such as int, double, char, or boolean.

4
New cards

Q: What are the 8 primitive data types in Java?

byte, short, int, long, float, double, char, boolean

5
New cards

Q: What is the default value of an int, boolean, and reference type in Java?

int: 0, boolean: false, reference type: null

6
New cards

Q: What is the difference between primitive and reference data types?

Primitive types store actual values; reference types store memory addresses of objects.

7
New cards

Q: What is a literal in Java?

A literal is a fixed value assigned to a variable, like 5, 'A', or "Hello".

8
New cards

Q: What are arithmetic operators in Java?

+, -, *, /, %

9
New cards

Q: What are relational (comparison) operators in Java?

==, !=, >,

10
New cards

Q: What are logical operators in Java?

&& (AND), || (OR), ! (NOT)

11
New cards

Q: What is the difference between = and == in Java?

= is the assignment operator, == compares values (or references for objects).

12
New cards

Q: What is type casting in Java?

Converting one data type into another. Example: (int) 5.5 gives 5.

13
New cards

Q: What is the difference between implicit and explicit casting?

Implicit casting is automatic (e.g., int to double), explicit casting is manual using (type) syntax (e.g., double to int).

14
New cards