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
Nested Scope Visibility: Outer Scope vs. Inner scope
Outer scope variables are visible to inner scope, but not vice versa.
26
Variable creation & destruction timeline
Variables are created when their scope is entered & destroyed when their scope is left.
27
Will a variable hold its value outside of its scope?
No
28
Will a method variable hold its value between calls to the method?
No
29
Variable lifetime limitation
Its scope
30
Can a variable declared in an inner scope have the same name as one declared in the outer scope?
No
31
Logical Operator: OR, AND
| | &
32
Logical Operator: XOR (Exclusive Or) Not
^ | !
33
Short-Circuit Logical Operators OR AND
Evaluate the second operant only when necessary || &&
34
Shorthand Increment Operator: | x+=10;
X = x + 10
35
What is Automatic type conversion?
Right value is converted to left side type
36
When does automatic type conversion take place?
When the two types are compatible & the destination type is larger than the source type.
37
Which primitives have no automatic type conversion?
Char & boolean
38
What is a cast?
An explicit instruction to convert one type into another.
39
Cast syntax
(target type) expression
40
Can you mix different types in an expression?
Yes, as long as they are compatible
41
Type Promotion Rules: what primitives convert to int when included with an int in an expression?
Char, byte, short
42
Precedence of Type Promotion for double, long & float
Long Float Double
43
Should you rely on type Promotion or casting?
Casting is more reliable than type promotion rules