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
What happens if a class implements two interfaces that both declare the same default method with identical signatures?
Answer: A compilation error occurs unless the class overrides the method
When two interfaces provide a default method with the same signature, the implementing class must override the method to resolve the conflict, or a compilation error results.
Which statement about abstract methods is correct?
Answer: A class with one abstract method must be declared abstract
If a class contains even one abstract method it must itself be declared abstract, otherwise a compilation error occurs.
What is the result of `'A' + 1` in Java?
Answer: 66
char is promoted to int during arithmetic; 'A' has the value 65, so 65 + 1 = 66.
In Java, which of the following correctly describes method overloading?
Answer: Two methods in the same class share a name but differ in parameter list
Overloading occurs when multiple methods in the same class have the same name but different parameter types or counts.
What is the scope of a variable declared inside a `for` loop initializer?
Answer: The for loop block and its update expression
A variable declared in the `for` initializer is scoped to the entire for statement including its condition, body, and update expressions.
Which of the following is true about Java's `this` reference?
Answer: It is implicitly passed to every instance method
`this` is an implicit reference to the current object and is silently available in every instance (non-static) method.
What modifier must a field have to be accessible from a static method in the same class?
Answer: static
Static methods belong to the class rather than an instance, so they can only directly access fields that are also declared static.