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
- What is the purpose of 'indexing' in a database?
- In a relational database, what is a foreign key?
- A relation is decomposed into R1(A,B) and R2(B,C). Which condition guarantees a lossless join for a binary decomposition?
- Given a relation R(A, B, C, D, E) and functional dependencies {A -> B, BC -> D, D -> E}. Which of the following is a candidate key for R?
- Given the following Python-like code snippet: ```python class Counter: def __init__(self): self.count = 0 def in...
- Distributed 2-Phase Commit (2PC) can suffer from:
- Which join should be used when you want to list all customers and any orders they may have placed, including customers who haven’t placed any orders?
- A relation Student_Course(StudentID, CourseID, StudentName, CourseName) stores StudentName redundantly in every row for each course a given student takes. ...
- Multiversion Concurrency Control (MVCC) ensures:
- A designer wants to remove a transitive dependency of a non-key attribute on a candidate key. Which normal form directly addresses this?
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)