โ† All 1Z0-819 Flashcard Decks

Java Fundamentals & Object-Oriented Programming Flashcards

7 cards from real 1Z0-819 practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Java Fundamentals & Object-Oriented Programming flashcards as text
  1. Which of the following is an example of a widening primitive conversion?

    Answer: int to long

    Converting int to long is widening because long can represent all values an int can hold without data loss.

  2. What is the output of: `System.out.println("5" + 2 + 3);`?

    Answer: 523

    String concatenation is left-associative: `"5" + 2` yields `"52"`, then `"52" + 3` yields `"523"`.

  3. Which OOP principle does encapsulation primarily support?

    Answer: Hiding internal implementation details behind a public interface

    Encapsulation bundles data and methods together and restricts direct access to internal state, exposing only a controlled public API.

  4. In Java, what is a 'has-a' relationship implemented through?

    Answer: Composition (field reference)

    A 'has-a' relationship is modeled by composition: one class holds a reference to another class as a field.

  5. What happens when you try to instantiate an abstract class directly with `new AbstractClass()`?

    Answer: A compilation error occurs

    The Java compiler rejects any attempt to instantiate an abstract class, producing a compilation error.

  6. Which of the following best describes the difference between `==` and `.equals()` for String objects?

    Answer: `==` compares references; `.equals()` compares content

    `==` tests reference equality (same object in memory), while `String.equals()` tests value equality (same character sequence).

  7. What is the purpose of a no-argument (no-arg) constructor?

    Answer: It enables object creation without providing initial field values

    A no-arg constructor allows a class to be instantiated without any arguments, which is also required by many frameworks for reflection-based object creation.