Chapter 3-2 Flashcards

1
Q

type variableName = value;
Where type is one of Java’s types (such as int or String), and variableName is the
name of the variable (such as x or name). The equal sign is used to assign values
to the variable.

A

Syntax

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

These unique names are called

A

Identifiers

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

The general rules for naming variables are:

A
  1. Names can contain letters, digits, underscores, and dollar signs
  2. Names must begin with a letter
  3. Names should start with a lowercase letter and it cannot contain
    whitespace
  4. Names can also begin with $ and _ (but we will not use it in this tutorial)
  5. Names are case sensitive (“myVar” and “myvar” are different variables)
  6. Reserved words (like Java keywords, such as int or boolean) cannot be
    used as names
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Kinds of Variables

A
  1. Local Variable
  2. Instance Variable
  3. Static Variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

____ variables are declared in methods, constructors, or blocks. _____variables are created when the method, constructor or block is entered
and the variable will be destroyed once it exits the method, constructor, or
block. Access modifiers cannot be used for _____

A

Local Variable

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

_____ variables are declared in a class, but outside a method, constructor or any block. _____ variables are created when an object is created with the use of the keyword ‘new’ and
destroyed when the object is destroyed. Access modifiers can be given for _____

A

Instance Variable

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

Static Variable

A

Class variables also known as _____ variables are declared with the static keyword in a class, but outside
a method, constructor or a block. _____ variables can be accessed by calling with the class name ClassName.VariableName.

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