Flashcards

Quick study sessions to strengthen memory and retain key concepts.

Flashcard Study

Java: Object References

Front

Why does reference vs copied data matter?

Reference vs copied data determines if objects share the same data or have independent copies. Understanding the difference…

View Card →
Flashcard Study

Java: Object References

Front

How do constructors help with object creation?

Constructors initialize new objects with default or specified values. Constructors are special methods used to initialize objects. They…

View Card →
Flashcard Study

Java: Object References

Front

How would you explain an object reference in a Java interview?

An object reference in Java is a variable that holds the memory address of an object. In Java,…

View Card →
Flashcard Study

Java: Object References

Front

What does an object reference give you?

A link from one object to another object in the model. A `CartItem` can point to a `Product`…

View Card →
Flashcard Study

Java: Object Interaction

Front

How can awkward interaction patterns be identified?

Look for direct field access and duplicated logic. Awkward interaction patterns can often be spotted by looking for…

View Card →
Flashcard Study

Java: Object Interaction

Front

What is method overloading?

Providing multiple methods with the same name but different parameters. Method overloading allows a class to have multiple…

View Card →
Flashcard Study

Java: Object Interaction

Front

Why encapsulate fields in a class?

Encapsulation protects the internal state. Encapsulation ensures that fields within a class are accessible only through methods, protecting…

View Card →
Flashcard Study

Java: Object Interaction

Front

Why avoid `CartItem` duplicating `Product` fields?

It leads to redundancy and maintenance problems. Duplicating fields like `name` and `price` in `CartItem` creates redundancy, making…

View Card →
Flashcard Study

Java: Object Interaction

Front

How does a constructor aid in object creation?

Constructors initialize objects with specific states. A constructor sets up a new object with initial values, ensuring it's…

View Card →
Flashcard Study

Java: Object Interaction

Front

Why does a method in object interaction matter in this design?

Methods enable controlled data exchange and actions. Methods act as the interface through which objects interact, allowing them…

View Card →