Flashcards

Quick study sessions to strengthen memory and retain key concepts.

Flashcard Study

Java: Object Interaction

Front

How would you explain an instance variable in a Java interview?

An instance variable is a variable defined in a class, for which each instantiated object of the class…

View Card →
Flashcard Study

Java: Object Interaction

Front

What issue arises if a `CartItem` duplicates `Product` fields?

Data inconsistency and redundancy. Frame the concept in practical terms so you can explain it during interview discussion.…

View Card →
Flashcard Study

Java: Object Interaction

Front

Why do objects collaborate through method calls?

Method calls allow objects to interact and perform tasks together. Objects collaborate by calling each other's methods to…

View Card →
Flashcard Study

Java: Object Interaction

Front

Why does a constructor in Java matter in this design?

A constructor initializes new objects. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: Object Interaction

Front

How do you know object collaboration is improving?

Each object contributes one understandable part of the workflow instead of one giant method doing everything. A cleaner…

View Card →
Flashcard Study

Java: Method Overriding

Front

Why use method overriding for behavior specialization?

To customize behavior in subclasses. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: Method Overriding

Front

What role does the 'super' keyword play in method overriding?

It accesses the superclass method. Frame the concept in practical terms so you can explain it during interview…

View Card →
Flashcard Study

Java: Method Overriding

Front

How can method overriding lead to a compile-time error?

If the overridden method changes visibility or throws new exceptions. When overriding, you cannot reduce the visibility of…

View Card →
Flashcard Study

Java: Method Overriding

Front

What happens if you forget the @Override annotation?

The method may not override the intended superclass method. Forgetting the @Override annotation can lead to subtle bugs.…

View Card →
Flashcard Study

Java: Method Overriding

Front

How can you ensure overridden methods maintain the Liskov Substitution Principle?

Ensure the subclass methods fulfill the same contract as the superclass methods. To adhere to the Liskov Substitution…

View Card →