Unit 3 Java Fundamentals Part 2 Flashcards

(10 cards)

1
Q

What are Binary Operands

A

-Must have two operands
-Must have a left and a right operand
-Cannot divide numbers by 0

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

What is integer division

A

-When both numbers are integers, Java drops any decimal part
-eg: 1/2= 0.5, then drops .5 so =0
-If you want a decimal, at least one number must be a decimal (double)

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

What is a combined assignment operator

A

-Lets you do math operation and assignment at the same time instead of two steps

Example:

x=x+5; is the same as x +=5;

Example:
int x =10;
x+=5;
y was 20, divide by 4, y=5

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

Rank the Primitive Data types

A

Highest to lowest:

Double
float
long
int
short
byte

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

What are widening conversions

A

-When a value of a lower ranked data type is assigned to a variable of a higher ranked data type

example:

double x;
int y =10;
x=y;

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

What are narrowing conversions

A

When a value of a higher ranked data type is assigned to a variable of a lower ranked data type

example:
int x;
double y=2.5;
x=y;
doesn’t work

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

What are cast openers

A

-Cast opener tells Java to do the narrowing conversion anyways even if it loses data
-To do this you use parentheses with the type name before the value you want to convert

Example:

int x;
double y=2.5;
x=(int) y;

x=2; (the 0.5 is gone because it cuts off)

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

What are constants

A

-Allow the programmer to use a name rather than a value throughout the program
-Constants are identifiers that hold only a single value
-They are declared using the keyword final
-Constants are all uppercase and words are separated by the underscore character

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

What are the three types of comments

A

1.Single line comments: place // where you want comment to begin and the compiler ignores everything from that point to the end of the line
2.Multiline Comments: Start with /* end with */ and everything between these markers is ignored. Can span multiple lines
3.Documentation comments: Comments that start with /** and ends with */. documentation comments are used before a class header, giving a brief description of the method or each method header, giving a brief description of the method

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

What is Scope

A

-Scope means the part of a program where a variable exists and can be accessed
-In java, a variables scope begins where it is declared and it ends when the block ({}) it belongs to ends

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