Java Unit 3 Flashcards

1
Q

What are “access specifiers”?

A

Modifiers are considered “access specifiers” and include “public”, “private”, “static” to name a few.

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

What does void mean when using it in the following code?
public static void main(String[] args) {}

A

void means there is no return-type. Meaning it’s not going to return anything to the program.

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

Any time the variable is used in an expression, the value is fetched from that same memory, no matter where the expression is located in the program.
What kind of variable is this referring to?

A

A static member variable

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

What is the purpose of defining subroutines (methods) within classes in Java?

A

Subroutines in Java classes group related code, aid organization, and enable code reuse.

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

In Java, what is the distinction between static and non-static subroutines?

A

Static subroutines are class-level and don’t need instances; non-static subroutines belong to objects.

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

How are static subroutines different from non-static subroutines in terms of their usage in a program?

A

Static subroutines are part of the class, called using the class name. Non-static subroutines are object-specific.

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

What are the modifiers commonly used in subroutine definitions in Java, and what do they specify?

A

Modifiers like “public,” “private,” “protected,” and “static” control subroutine access.

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

What is the role of the return type in a Java subroutine definition, and what does “void” signify?

A

The return type specifies what a subroutine returns, with “void” indicating no return value.

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

Explain what parameters are in a Java subroutine and how they are used.

A

Parameters are values passed into a subroutine for processing.

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

In Java, how can you call a static subroutine defined in the same class?

A

To call a static subroutine in the same class, use methodName();.

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

When calling a static subroutine defined in a different class, what format should you use?

A

For static subroutines in different classes, use className.methodName();.

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

What is the difference between local variables and member variables (global variables) in Java classes?

A

Local variables are confined to subroutines; member (global) variables are class-wide.

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

How are static member variables initialized by default in Java?

A

Static member variables have default values: 0 for numeric types, false for boolean, ‘\u0000’ for char, and null for objects.

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