Java Unit 3 Flashcards
What are “access specifiers”?
Modifiers are considered “access specifiers” and include “public”, “private”, “static” to name a few.
What does void mean when using it in the following code?
public static void main(String[] args) {}
void means there is no return-type. Meaning it’s not going to return anything to the program.
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 static member variable
What is the purpose of defining subroutines (methods) within classes in Java?
Subroutines in Java classes group related code, aid organization, and enable code reuse.
In Java, what is the distinction between static and non-static subroutines?
Static subroutines are class-level and don’t need instances; non-static subroutines belong to objects.
How are static subroutines different from non-static subroutines in terms of their usage in a program?
Static subroutines are part of the class, called using the class name. Non-static subroutines are object-specific.
What are the modifiers commonly used in subroutine definitions in Java, and what do they specify?
Modifiers like “public,” “private,” “protected,” and “static” control subroutine access.
What is the role of the return type in a Java subroutine definition, and what does “void” signify?
The return type specifies what a subroutine returns, with “void” indicating no return value.
Explain what parameters are in a Java subroutine and how they are used.
Parameters are values passed into a subroutine for processing.
In Java, how can you call a static subroutine defined in the same class?
To call a static subroutine in the same class, use methodName();.
When calling a static subroutine defined in a different class, what format should you use?
For static subroutines in different classes, use className.methodName();.
What is the difference between local variables and member variables (global variables) in Java classes?
Local variables are confined to subroutines; member (global) variables are class-wide.
How are static member variables initialized by default in Java?
Static member variables have default values: 0 for numeric types, false for boolean, ‘\u0000’ for char, and null for objects.