Intro to programming UNIT 2 Flashcards

1
Q

How many characters does ASCII and UNICODE share?

A

The first 256 Characters

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

Why do you specify datatypes

A

It tell the compiler how much memory to set aside for the variable and how to interpret the data in memory

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

What naming convention do you use for a class

A

TitleCase. Every word is capitalized and has no spaces

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

What are the datatypes for whole numbers and how many bits does each use

A

byte (8 bits)
short (16 bits)
int (32 bits)
long (64 bits)

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

What is the naming convention for variable names

A

camelCase. The first word is not capitalized and every word after is capitalized

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

What makes a valid variable name

A

Must start with a letter, underscore or a dollar sign
Cannot start with a digit
Not a java reserved keyword

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

What is the naming convention for constants

A

Every Letter is capitalized and spaces are underscores

TAX_RATE

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

How do you declare a constant?

A

Using the final keyword

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

What are variable names also known as

A

Identifier
Reference
Handle

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

What is the only thing in java that is not an object?

A

Primitive data types

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

How many primitive datatypes are there in java

A

Eight

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

What are the two non numeric data types? And what are their sizes?

A

char (16 bits) - will hold a single unicode value
boolean (8 bits) - will hold a true false value

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

What are the signed floating point data primitives and their sizes

A

float (32 bits)
double (64 bits)

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

What is the var datatype?

A

It’s an inferred datatype. The compiler looks at the data going into the variable and chooses the correct data type for it

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

When can you use the var datatype?

A

It can only be used when creating local variables within a method

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

What is a data literal?

A

A data literal is data stored within a program

i.e: int ryanAge = 22;

22 would be the data literal

17
Q

How do you indicate that a data literal is a certain type?

A

When the var is a long add L to the suffix

i.e: long ryanAge = 10000000000000L;

Suffix a long by an L for it to be considered a long instead of an int

18
Q

What happens when you divide two integers?

A

Java will truncate the result.

ie: 5 / 2 = 2.

it will simply remove the decimal point. IT WILL NOT ROUND OFF NUMBERS

19
Q

What do you call a variable?

A

An identifier

20
Q

What does ‘m’ represent

A

It represents a char literal

21
Q

How do you get 1 char from the Scanner?

A

input.next().charAt(0);

22
Q

When the compiler assumes the conversion what is this called

A

An implicit conversion

23
Q

What is an operator

A

An operator is a symbol that performs built-in calculations

24
Q

How do you import the random function

A

import java.util.Random;

25
Q

How do you create a Random object (java.util.Random) named randGen

A

Random randGen = new Random();

26
Q

How do you get a random integer from a Random object named randGen

A

randGen.nextInt();