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 && year <= 2025) { // Basic validation this.year = year; } else { System.out.println("Invalid year."); } } } In this `Car` class, the `model` and `year` fields are declared as `private`. This practice, combined with providing public `get` and `set` methods to access and modify these fields, is a core principle of Object-Oriented Programming known as _______________. It helps in bundling data (fields) and methods that operate on the data within a single unit, and restricting direct access to some of the object's components.
More IT DBMS Questions
- If every non-key attribute is functionally dependent on the primary key, the relation will be in
- Transaction T1 reads a row twice within the same transaction. Between the two reads, T2 commits an update to that row, and T1's second read returns the new...
- Which of the following is a type of database index?
- Shadow paging in recovery eliminates the need for:
- Which concurrency anomaly is specific to phantom reads?
- A relation R(A, B, C, D, E) has the functional dependencies AB→C, C→D, D→E, and E→A. Assuming AB is the only candidate key of R, which normal form does R s...
- Which normal form removes transitive dependency?
- Which type of attack exploits software bugs to execute arbitrary code on a system?
- Which type of join returns all rows from the left table and matching rows from the right table?
- Which of the following correctly describes a 'primary key' in a relational database?
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)