1-Building Blocks Flashcards

1
Q

Java Development Kit(JDK)

A

contains the minimum software you need

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

javac

A

Converts .java source files into .class bytecode

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

What command converts .java source files into .class bytecode

A

javac

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

java

A

executes the program

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

What command executes the program?

A

java

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

jar

A

Packages files together

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

What command packages files together?

A

jar

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

javadoc

A

Generates documentation

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

What command generates documentation?

A

javadoc

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

What are 2 primary elements of Java classes?

A

1.Methods (functions, procedures)
2.Fields (variables)

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

What is an object?

A

A runtime instance of a class in memory.

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

An object is often referred to?

A

As an instance.

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

What does an instance represent?

A

A single representation of the class.

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

What is a reference?

A

A variable that points to an object.

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

What are methods and fields of a class called together?

A

Members

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

What is a top-level type?

A

A data structure that can be defined independently within a source file/

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

Is it possible to have 2 top-level types in the same file?

A

yes, at most on of those is allowed to be public. And the public top-level type needs to match the filename.

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

What do you call the shortcut for both javac and java? for example java Zoo.java ...args

A

single-file source-code

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

Naming conflicts: What if you need two Classes with the same name from different packages?

A
  1. pick one to use in the import statement and use the other fully qualified class name.
    2.Use the fully qualified class name for both.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Compiling with wildcards: how do you use an asterisk with javac command?

A

you specify to include all Java files in a directory, cannot be used to include subdirectories.

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

compiling to another directory?

A

javac -d directoryname package/class.java

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

how to run programs compiled to another directory?

A

java -cp/-classpath/–class-path directoryname packagename.Classname

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

What are important javac options?

A
  1. -cp <classpath></classpath>
  2. -classpath <classpath></classpath>
  3. –class-path <classpath></classpath>
  4. -d <dir></dir>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are important java options?

A
  1. -cp <classpath></classpath>
  2. -classpath <classpath></classpath>
  3. –class-path <classpath></classpath>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What are important jar options?

A
  1. -c (creates a new JAR file)
    –create
  2. -v (prints details when working with JAR files
    –verbose
  3. -f <fileName> JAR filename
    --file <fileName></fileName></fileName>
  4. -C <directory> (Directory containing files to be used to create the JAR</directory>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

rules for what Java file contains

A
  • Each file can contain only one public class
  • The filename must match the class name, including case, and have .java extension
  • If entry point for the program, must contain valid main() method.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which modifiers are optional in the next main() method:
public final static void main(final String[] args) {}

A

Both final modifiers

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

How do you call the following:
java Zoo.java zoo

shortcut for: javac Zoo.java \n java Zoo Zoo

A

launching single-file source-code programs

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

Required?

Package declaration

package abc;

A

No

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

Required?

import statements

import java.util.*;

A

No

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

Required?

Top-level type declaration

public class C

A

Yes

32
Q

Required?

Field declarations

int value;

A

No

33
Q

Required?

Method declarations

void method()

A

No

34
Q

Where does it go?

Package declaration

package abc;

A

First line in the file

excluding comments or blank lines

35
Q

Where does it go?

import statements

import java.util.*;

A

Immediately after the package (if present)

36
Q

Where does it go?

Top-level type declarations

public class C

A

Immediately after import statements (if any)

37
Q

Where does it go?

Field declarations

int value;

A

Any top-level element within a class.

38
Q

Where does it go?

Method declarations

void method()

A

Any top-level elemant within a class.

39
Q

What is the

Order of Initialization?

A
  1. Fields and instance initializer blocks are run in the order in which they appear in the file.
  2. Constructor runs after all fials and instance initializer blocks have run.
40
Q

What are the

built-in data types of Java?

primitives

A
  1. boolean
  2. byte
  3. short
  4. int
  5. long
  6. float
  7. double
  8. char
41
Q

Type, min value, max value, default value and an example of:

boolean

A
  1. true or false
  2. n/a
  3. n/a
  4. false
  5. true
42
Q

Type, min value, max value, default value and an example of:

byte

A
  1. 8-bit integral value
  2. -128
  3. 127
  4. 0
  5. 123
43
Q

Type, min value, max value, default value and an example of:

short

A
  1. 16-bit integral value
  2. -32768
  3. 32767
  4. 0
  5. 123
44
Q

Type, min value, max value, default value and an example of:

int

A
  1. 32-bit integral value
  2. -2147483648
  3. 2147483647
  4. 0
  5. 123
45
Q

Type, min value, max value, default value and an example of:

long

A
  1. 64-bit integral value
  2. -2⁶³
  3. 2⁶³ -1
  4. 0L
  5. 123L
46
Q

Type, min value, max value, default value and an example of:

float

A
  1. 32-bit floating-point value
  2. n/a
  3. n/a
  4. 0.0f
  5. 123.45f
47
Q

Type, min value, max value, default value and an example of:

double

A
  1. 64-bit floating-point value
  2. n/a
  3. n/a
  4. 0.0
  5. 123.456
48
Q

Type, min value, max value, default value and an example of:

char

A
  1. 16-bit Unicode value
  2. 0
  3. 65535
  4. \u0000
  5. ‘a’
49
Q

Is String a Primitive?

A

No. String is often mistaken for ninth primitive because Java includes built-in support for String literals and operators.

50
Q

Which types of data contain Java applications?

A
  1. primitive types
  2. reference types
51
Q

What are:

byte, short, int, long types used for?

A

integer values without decimal points

52
Q

How much bits are used by numeric types?

A

each type uses twice as many bits as the smaller similar type.

short uses twice as many bits as byte does.

53
Q

How do numeric types cover the negative range?

A

All of the numeric types are signed and reserve one of their bits to cover a negative range.

54
Q

What is required for a float?

A

The letter f or F, otherwise Java interprets a decimal value as a double.

55
Q

What is required for long?

A

The letter l or L, number without a decimal point without an l or L is interpreted as an int in most scenarios.

56
Q

What is de difference between short and char?

A

short is signed, a range across positive and negative integers.
char is unsigned, strictly positive including 0.

57
Q

which other digit formats are allowed by Java?

A
  1. Octal
  2. Hexadecimal
  3. Binary
58
Q

How do you recognize:

Octal?

A

0 as a prefix

017

59
Q

How do you recognize:

Hexadecimal?

A

0x or 0X as a prefix

0xFF

60
Q

How do you recognize:

Binary?

A

0b or 0B as a prefix

0b10

61
Q

When using an underscore to make numbers more readable, where can’t they go?

A
  1. at the beginning of a literal
  2. at the end of a literal
  3. right before a decimal point
  4. right after a decimal point
62
Q

In which ways can a value be assigned to a reference?

A
  1. A reference can be assigned to another object of the same or compatible type.
  2. A reference can be assigned to a new object using the new keyword.
63
Q

What is the Wrapper class of

boolean? And does it inherit Number?

A

Boolean
No

Boolean.valueOf(true)

64
Q

What is the Wrapper class of byte?
And does it inherit Number?

A

Byte
yes

Byte.valueOf( (byte) 1)

65
Q

What is the Wrapper class of short?
And does it inherit Number?

A

Short
yes

Short.valueOf( (short) 1)

66
Q

What is the Wrapper class of int?
And does it inherit Number?

A

Integer
yes

Integer.valueOf(1)

67
Q

What is the Wrapper class of long?
And does it inherit Number?

A

Long
yes

Long.valueOf(1)

68
Q

What is the Wrapper class of float?
And does it inherit Number?

A

Float
yes

Float.valueOf( (float) 1.0)

69
Q

What is the Wrapper class of doubld?
And does it inherit Number?

A

Double
yes

Double.valueOf(1.0)

70
Q

What is the Wrapper class of char?
And does it inherit Number?

A

Character
No

Character.valueOf(‘c’)

71
Q

What is essential whitespace?

A

Part of your string and is important to you.

72
Q

What is Incidental whitespace?

A

whitespace to make the code easier to read.

73
Q

What does it mean in regular string and text block:

"

A
  • Regular String: "
  • Text block: "
74
Q

What does it mean in regular string and text block:

"””

A
  • Regular String: n/a - invalid
  • Text block: """
75
Q

What does it mean in regular string and text block:

"””

A
  • Regular String: n/a - invalid
  • Text block: """