Exam Essentials 1 bag 41 Flashcards

1
Q

Be able to write code using a main() method.

A main() method is usually written as public static void main(String[] args).

Arguments are referenced starting with args[0]. Accessing an argument that wasn’t passed in will cause the code to ___ an ___

A

throw and exception

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

Understand the effect of using packages and imports.

A ___ has the same name as the ____.
It looks like a method without a ____ ____

A

constructor

return type

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

Be able to identify legal and illegal declarations and instantiations.

Multiple variables can be ____ and _____ in the same statement when they share a ___.

A

declared
instantiated
type

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

___ variables require an explicit initialization.

A

Local variables

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

_____ may contain:

____, ____, ___ and ___.

A
Identifiers
letters
numbers
$
_
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Identifiers may not begin with ____

A

numbers

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

_____ ____ may contain ____ between numbers.

A

Number literals

underscores

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
Number literal may begin with
_- _ (decimal)
_ (octal)
\_\_ and \_\_ (hex)
\_\_ and \_\_ (binary)
A

0-1
0
0x and 0X
0b and 0B

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

Be able to determine where variables go into and out of scope.

All variables go into scope when they are ___.

A

declared

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

____ variables go out of scope when the block they are declared ___

A

local

ends

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

____ variables go out of scope when the object is garbage collected.

A

instance variables

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

___ variables remain in scope as long as the program is running.

A

class variables

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

An instance variable goes out of scope when the object is ___ ____

A

garbage collected

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

Class variables remain in scope as long as the ___ is running

A

program

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

Be able to recognize misplaced statements in a class.

T or F
Package and imports statements are optional.

A

True

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

In what order does package and imports statement go?

A

package statement

import statment

17
Q
T or F
Does the package and import statement go after the class declaration?
A
False.
They go before the class declaration
18
Q

T or F

Are fields and methods optional?

A

True

19
Q

In what order are fields and methods allowed within the class declaration.

A

In any order

20
Q

Know how to identify when an object is eligible for garbage collection.

Draw a diagram to keep track of references and objects as you trace the code.

  • When no arrows point to a box (object), it is eligible for garbage collection.
A

:)

You got this!

21
Q

T or F

Identifiers apply to anything you are free to name?

A

True

22
Q

Whare are examples of identifiers which you are free to name?

A

variables
methods
classes and
fields

23
Q

What are the only three rules for legal identifiers?

  1. The name must begin with a __ or the symbol _ or _.
  2. Subsequent characters may also be ___.
  3. You cannot use the same name as a Java __ word.
A
  1. The name must begin with a letter, symbol & or underscore.
  2. numbers
  3. Reserved
24
Q

What is a reserved word?

A

A reserved word is a keyword that Java has reserved.

You are not allowed to use it.

25
Q

T or False

Java is case sensitive

A

True

26
Q

Name one reserved word

A

Class