Data Types & Operators Flashcards

1
Q

Primitive Integer Types

A

4 - byte, short, int, long

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Primitive Floating-Point Types

A

2 - float, double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Primitive Non-Numeric Types

A

2 - char, boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Number of Primitive Types

A

8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Bits & Range: byte

A

8 bits

-128 to 127

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Bits & Range: short

A

16 bits

-32768 to 32767

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Bits & Range: int

A

32 bits

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Bits & Range: long

A

64 bits

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

char assignment uses what kind of quotes

A

Single quotes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Operator for testing Boolean values

A

==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Literals

A

Fixed values (constants) of any primitive type

Default is int

Postfix l or L for long or f or F for Float - 12L, 10.19f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Octal Literals

A

Number system based on 8, using digits 0-7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Hexadecimal Literals

A

Base 16 number system, using digits 0-9 plus A-F (10-15)

Prefix 0X or 0x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Binary Literals

A

Binary number

Prefix 0B or 0b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

String Literals

A

A set of characters enclosed in double quotes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Escape Sequences

A

A sequence of characters that does not represent itself when used inside a character or string literal, but is translated to a formatting specifier or character that is hard to represent. Backslash prefix.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

'
"
\

A

Single quote
double quote
Backslash escape sequence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

\t
\r
\b

A

Tab
Carriage Return
Backspace Escape Sequence

19
Q

\n

A

New line Escape Sequence

20
Q

\f

A

Form feed escape sequence- page break

21
Q

Variable Declaration

A

type variableName;

22
Q

Variable Initialization

A

type varName = value;

23
Q

Dynamic variable initialization

A

type varName = expression;

24
Q

Types of Scope

A

Class

Method

25
Q

Nested Scope Visibility: Outer Scope vs. Inner scope

A

Outer scope variables are visible to inner scope, but not vice versa.

26
Q

Variable creation & destruction timeline

A

Variables are created when their scope is entered & destroyed when their scope is left.

27
Q

Will a variable hold its value outside of its scope?

A

No

28
Q

Will a method variable hold its value between calls to the method?

A

No

29
Q

Variable lifetime limitation

A

Its scope

30
Q

Can a variable declared in an inner scope have the same name as one declared in the outer scope?

A

No

31
Q

Logical Operator: OR, AND

A

|

&

32
Q

Logical Operator:
XOR (Exclusive Or)
Not

A

!

33
Q

Short-Circuit Logical Operators
OR
AND

A

Evaluate the second operant only when necessary
||
&&

34
Q

Shorthand Increment Operator:

x+=10;

A

X = x + 10

35
Q

What is Automatic type conversion?

A

Right value is converted to left side type

36
Q

When does automatic type conversion take place?

A

When the two types are compatible & the destination type is larger than the source type.

37
Q

Which primitives have no automatic type conversion?

A

Char & boolean

38
Q

What is a cast?

A

An explicit instruction to convert one type into another.

39
Q

Cast syntax

A

(target type) expression

40
Q

Can you mix different types in an expression?

A

Yes, as long as they are compatible

41
Q

Type Promotion Rules: what primitives convert to int when included with an int in an expression?

A

Char, byte, short

42
Q

Precedence of Type Promotion for double, long & float

A

Long
Float
Double

43
Q

Should you rely on type Promotion or casting?

A

Casting is more reliable than type promotion rules