Question

Consider the following Java code snippet  public class Car {     private String model;     private int year;     public Car(String model, int year) {         this.model = model;         this.year = year;     }     public String getModel() {         return model;     }     public void setModel(String model) {         this.model = model;     }     public int getYear() {         return year;     }     public void setYear(int year) {         if (year > 1900 && yea

A Inheritance Correct Answer Incorrect Answer
B Polymorphism Correct Answer Incorrect Answer
C Abstraction Correct Answer Incorrect Answer
D Encapsulation Correct Answer Incorrect Answer

Solution

The correct answer is D

Practice Next
ask-question