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
What are important jar options?
1. -c (creates a new JAR file) --create 2. -v (prints details when working with JAR files --verbose 3. -f JAR filename --file 4. -C (Directory containing files to be used to create the JAR
26
rules for what Java file contains
* 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.
27
Which modifiers are optional in the next main() method: public final static void main(final String[] args) {}
Both final modifiers
28
How do you call the following: java Zoo.java zoo | shortcut for: javac Zoo.java \n java Zoo Zoo
launching single-file source-code programs
29
# Required? Package declaration | package abc;
No
30
# Required? import statements | import java.util.*;
No
31
# Required? Top-level type declaration | public class C
Yes
32
# Required? Field declarations | int value;
No
33
# Required? Method declarations | void method()
No
34
# Where does it go? Package declaration | package abc;
First line in the file | excluding comments or blank lines
35
# Where does it go? import statements | import java.util.*;
Immediately after the package (if present)
36
# Where does it go? Top-level type declarations | public class C
Immediately after import statements (if any)
37
# Where does it go? Field declarations | int value;
Any top-level element within a class.
38
# Where does it go? Method declarations | void method()
Any top-level elemant within a class.
39
# What is the Order of Initialization?
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
# What are the built-in data types of Java? | primitives
1. boolean 2. byte 3. short 4. int 5. long 6. float 7. double 8. char
41
# Type, min value, max value, default value and an example of: boolean
1. true or false 2. n/a 3. n/a 4. false 5. true
42
# Type, min value, max value, default value and an example of: byte
1. 8-bit integral value 2. -128 3. 127 4. 0 5. 123
43
# Type, min value, max value, default value and an example of: short
1. 16-bit integral value 2. -32768 3. 32767 4. 0 5. 123
44
# Type, min value, max value, default value and an example of: int
1. 32-bit integral value 2. -2147483648 3. 2147483647 4. 0 5. 123
45
# Type, min value, max value, default value and an example of: long
1. 64-bit integral value 2. -2⁶³ 3. 2⁶³ -1 4. 0L 5. 123L
46
# Type, min value, max value, default value and an example of: float
1. 32-bit floating-point value 2. n/a 3. n/a 4. 0.0f 5. 123.45f
47
# Type, min value, max value, default value and an example of: double
1. 64-bit floating-point value 2. n/a 3. n/a 4. 0.0 5. 123.456
48
# Type, min value, max value, default value and an example of: char
1. 16-bit Unicode value 2. 0 3. 65535 4. \u0000 5. 'a'
49
Is String a Primitive?
No. String is often mistaken for ninth primitive because Java includes built-in support for String literals and operators.
50
Which types of data contain Java applications?
1. primitive types 2. reference types
51
# What are: byte, short, int, long types used for?
integer values without decimal points
52
How much bits are used by numeric types?
each type uses twice as many bits as the smaller similar type. | short uses twice as many bits as byte does.
53
How do numeric types cover the negative range?
All of the numeric types are signed and reserve one of their bits to cover a negative range.
54
What is required for a float?
The letter f or F, otherwise Java interprets a decimal value as a double.
55
What is required for long?
The letter l or L, number without a decimal point without an l or L is interpreted as an int in most scenarios.
56
What is de difference between short and char?
short is signed, a range across positive and negative integers. char is unsigned, strictly positive including 0.
57
which other digit formats are allowed by Java?
1. Octal 2. Hexadecimal 3. Binary
58
# How do you recognize: Octal?
0 as a prefix | 017
59
# How do you recognize: Hexadecimal?
0x or 0X as a prefix | 0xFF
60
# How do you recognize: Binary?
0b or 0B as a prefix | 0b10
61
When using an underscore to make numbers more readable, where can't they go?
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
In which ways can a value be assigned to a reference?
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
# What is the Wrapper class of boolean? And does it inherit Number?
Boolean No | Boolean.valueOf(true)
64
What is the Wrapper class of byte? And does it inherit Number?
Byte yes | Byte.valueOf( (byte) 1)
65
What is the Wrapper class of short? And does it inherit Number?
Short yes | Short.valueOf( (short) 1)
66
What is the Wrapper class of int? And does it inherit Number?
Integer yes | Integer.valueOf(1)
67
What is the Wrapper class of long? And does it inherit Number?
Long yes | Long.valueOf(1)
68
What is the Wrapper class of float? And does it inherit Number?
Float yes | Float.valueOf( (float) 1.0)
69
What is the Wrapper class of doubld? And does it inherit Number?
Double yes | Double.valueOf(1.0)
70
What is the Wrapper class of char? And does it inherit Number?
Character No | Character.valueOf('c')
71
What is essential whitespace?
Part of your string and is important to you.
72
What is Incidental whitespace?
whitespace to make the code easier to read.
73
# What does it mean in regular string and text block: \"
* Regular String: `"` * Text block: `"`
74
# What does it mean in regular string and text block: \"""
* Regular String: `n/a - invalid` * Text block: `"""`
75
# What does it mean in regular string and text block: \"""
* Regular String: `n/a - invalid` * Text block: `"""`