Datatypes
Variables
Constants
Comments
Numbers in Java
100

Which datatype has only two values (true and false)?

boolean

100

How should you name a variable in Java?

lowerCamelCase

100

What is a constant?

A value that cannot be changed later on in the program.

100
What are the three types of comments that can be made in Java?

- single-line comments

- multi-line comments

- JavaDoc comments

100

What is the result of 7/5 in Java?

1

200

Which integer datatype provides the least accuracy?

byte

200

What is the problem with this variable name?

x

x is not specific and does not give any information about the data you are storing
200

How do you indicate that something is a constant?

With the reserved word "final" before the datatype in its declaration.

200

Which type of comment is indicated by /*  and */?

Multi-line comment

200

What is the result of 9.0/2 in Java?

4.5
300

What floating point datatype provides the most accuracy?

double

300

What is the problem with this variable name?

cans per pack

Variable names should not have a space, in order to separate words, you should use lowerCamelCase

300

How should you name a constant in Java?

UPPER_CASE_WITH_UNDER_SCORES

300

What type of comment is indicated by //?

Single-line comment
300

What are the two types of casting?

- explicit casting, must use (datatype) to cast

- implicit or up-casting

400

Name an example of a non-primitive datatype?

- string

- array

- object

400

What is needed for a variable declaration?

- datatype

- variable name

400

What is convenient about using the same constant in multiple locations in your program?

If you change the value of the constant, places where you used the constant's name will not need to be updated.

400

What type of comment is indicated by /** and */?

JavaDoc comment
400

What may happen if you store a value as a datatype that does not have enough accuracy for your value?

Overflow error

500

What is the difference between a primitive and non-primitive datatype?

- Primitive datatypes are hardcoded into the language

- Non-primitive datatypes are classes and object-oriented


500

What is needed to initialize/assign a variable?

- variable name

- value

500

When should you use a constant?

When you are going to use a literal value in your program that others may not understand the significance of.

500

Name a place where it would be best practice to place a comment.

- beginning of file/class

- beginning of method

- explanation for anything with an unclear name

500

What is a common error that can occur with floating point numbers?

Roundoff error due to values being stored in binary