Java Flashcards

Learn java

1
Q

When would one use a query parameter over a stashed field (stashed in the header)?

A

When one wants to allow for a value of 0. Stashed parameters do not allow that.

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

What is the entry point of a java class?

A

public static void main(String[] args)

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

What’s the syntax to create a Set of the numbers 1, 2, 3?

A

Set<Integer> set = Set.of(1, 2, 3)</Integer>

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

What are access modifiers, and what are they in Java?

A

Control which other classes can access a particular area of code.

Private, public, protected, and default.

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

What is this syntax? MyObject<K,V>?

A

Generics.

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

Syntax to create an error when a bad input is found.

A

throw new IllegalArgumentException(“new error”)

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

What’s the difference between raise and throw?

A

Raise is for python, throw is for java.

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