Podcast
Questions and Answers
In Java, it is possible to write a method that will return ________.
In Java, it is possible to write a method that will return ________.
a string of characters, a whole number, and a reference to an object
Java automatically stores a ________ value in all uninitialized static member variables.
Java automatically stores a ________ value in all uninitialized static member variables.
0 (zero)
Static methods can only operate on ________ fields.
Static methods can only operate on ________ fields.
static
The 'has a' relationship is sometimes called a(n) ________ because one object is part of a greater whole.
The 'has a' relationship is sometimes called a(n) ________ because one object is part of a greater whole.
Signup and view all the answers
The key word this is the name of a reference variable that an object can use to refer to itself.
The key word this is the name of a reference variable that an object can use to refer to itself.
Signup and view all the answers
The whole-part relationship created by object aggregation is more often called a(n) ________ relationship.
The whole-part relationship created by object aggregation is more often called a(n) ________ relationship.
Signup and view all the answers
To compare two objects in a class, ________.
To compare two objects in a class, ________.
Signup and view all the answers
When a field is declared static there will be ________.
When a field is declared static there will be ________.
Signup and view all the answers
When a method's return type is a class, what is actually returned to the calling program?
When a method's return type is a class, what is actually returned to the calling program?
Signup and view all the answers
When a reference variable is passed as an argument to a method ________.
When a reference variable is passed as an argument to a method ________.
Signup and view all the answers
When an object is passed as an argument, it is actually a reference to the object that is passed.
When an object is passed as an argument, it is actually a reference to the object that is passed.
Signup and view all the answers
When an object reference is passed to a method, the method may change the values in the object.
When an object reference is passed to a method, the method may change the values in the object.
Signup and view all the answers
Study Notes
Java Methods and Variables
- A Java method can return various data types including strings, whole numbers, and object references.
- Uninitialized static member variables in Java are automatically assigned a default value of zero.
- Static methods are restricted to operating only on static fields within a class.
Object Relationships
- The "has a" relationship, also known as a whole-part relationship, signifies that one object is a component of another.
- Object aggregation is frequently characterized by this whole-part relationship.
Self-Referencing and Object Comparison
- The keyword
this
serves as a reference variable that allows an object to refer to itself. - To compare two objects, an
equals
method should be implemented to perform a field-by-field comparison.
Static Fields and Memory Management
- When a field is declared as static, there is only a single copy stored in memory, regardless of how many instances of the class exist.
- Methods whose return types are classes return references, not the objects themselves, to the calling program.
Passing References to Methods
- When a reference variable is used as a method argument, the method gains access to the actual object referenced by that variable.
- Passing an object as an argument corresponds to passing a reference to that object.
- Methods that receive an object reference can modify the object's internal values.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Explore key concepts in Java programming, focusing on methods, variables, and object relationships. Understand how static fields operate and the importance of the 'this' keyword in self-referencing objects. This quiz will enhance your knowledge of Java's unique features and memory management techniques.