Building Blocks Flashcards

1
Q

Java compile command?

A

javac

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

What is compiler command for setting the compile output directory?

A

-d

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

How does typical compile command look like? What are its parts?

A
  1. -d for output directory
  2. name of class we compile or package path to class or package path with * for all classes in that package
  3. -cp or -classpath or –class-path for dependency folder or folder where is application built
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to set classpath location while using compiler command and all its variants?

A

-cp
-classpath
–class-path

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

How to run Java application using CLI?

A

java

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

What do you need to provide “java” command to run Java application?

A

Package path to class that has main method we want to run, and complete classpath

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

How do text block look like?

A

”””
text block”””

Note: it needs to have first line below opening quotes!

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

In text blocks, how do we request a new line in output?

A

\n

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

In text blocks, how do we request not to add a new line?

A

\

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

In text blocks, how do we escape characters?

A

\ and some character
eg. "

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

In text blocks, how do we request two spaces in output?

A

\s

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

What is command to JAR a Java application?

A

jar

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

How do we choose dependency folder while using “jar” command?

A

-c

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

How do we JAR a Java application?

A

jar -cvf JarName.jar -c dependency/folder .

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

What is alternative to “-cvf”

A

–create –verbose –file

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

What do we need to watch out when using imports?

A

We need to look for imports with the same name

17
Q

What are rules when using wildcard * in imports?

A
  • can only import classes, not subpackages.
    When specific import is defined, it trumps wildcard.
18
Q

What are rules when naming identifiers?

A
  • Name cannot start with numbers
  • Symbols at start can only be $ or _
  • _ cannot be used as name
  • Reserved keyword cannot be used as name
19
Q

What are rules for local variables?

A

They must be initiated before use

20
Q

Where can “var” be used?

A

Only with local variables

21
Q

What is rule when using “var”?

A

Its value must be set in the same line as var, not later

22
Q

Is “var” reserved keyword?

A

No, it can be used as identifier - var var = new Var();

23
Q

public int addition(var a, var b)?

A

var cannot be used as parameter as parameters are not local variables

24
Q

What is rule for initialization of variables in same line?

A

Only one variable type can be defined per line - int a, b, c = 5

25
What is the order of instance initialization?
- Fields and instance initializers ({}) are initialed in order they appear in class - Constructor is initialized after them
26
When are static initializers being run?
When class is first loaded
27
When are instance initializers being run?
When new class instance is being defined
28
What are Java primitives?
boolean byte short char int long float double
29
What two primitives are similar?
char and short, both 16 bit
30
How do we call numbers in Java?
Literals
31
What are signed and unsigned primitives?
Those primitives that go from negative number to positive number (as range)
32
How do we parse a primitive?
eg. parseInt() etc.
33
How do we return wrapping class from primitive?
with "valueOf()" method
34
How can primitives also be written?
- hexadecimal - octal - binary
35
How do we write binary literals?
0b0101 0B1010
36
How do we write hexadecimal literals?
0xF23
37
How do we write octal literals?
012 053 032
38
java.lang package
Doesnt need import, it is auto. imported