1Z0-829 Instance variable Practice Question
Exhibit
Refer to the exhibit.
```
-- SQL to create table
CREATE TABLE departments (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(50)
);
-- Materialized view with refresh
CREATE MATERIALIZED VIEW dept_summary
REFRESH COMPLETE ON DEMAND
AS
SELECT dept_id, COUNT(*) AS emp_count
FROM employees
GROUP BY dept_id;
-- Query
SELECT * FROM dept_summary;
```What is a key difference between a class and an interface in Java?
⚠ Common exam trap
Candidates might think that interfaces can have instance variables in Java 8+ with default methods, but interfaces still cannot have instance variables.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
A class can contain instance variables, while an interface cannot.
Classes can have instance variables (state), while interfaces cannot (they only declare method signatures and constants). This is a fundamental Java OOP concept.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
A class cannot be used in inheritance.
Why it's wrong here
Incorrect. Classes support inheritance; a class can extend another class or implement interfaces.
- ✓
A class can contain instance variables, while an interface cannot.
Why this is correct
Correct. A class can contain instance variables, while an interface cannot.
- ✗
An interface is automatically updated when the implementing class changes.
Why it's wrong here
Incorrect. Interfaces are not automatically updated; changes to implementing classes do not affect the interface definition.
- ✗
An interface can be instantiated directly.
Why it's wrong here
Incorrect. Interfaces cannot be instantiated directly; they must be implemented by a class.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.