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
- Consider the following Java-like pseudo-code for inserting a node into a Binary Search Tree (BST): ```java class Node { int data; ...
- Two transactions T1 and T2 both follow the Two-Phase Locking (2PL) protocol. T1 acquires an exclusive lock on row A and then requests a lock on row B, whil...
- Which of the following is a weak entity in a database?
- What does the ‘’ element in HTML5 allow you to do?
- Which of the following is a DML command?
- When debugging a recursive function that processes a `Tree` data structure, what is a common strategy to identify infinite recursion or incorrect base case...
- Which constraint ensures that a column contains only unique values, but allows NULL values?
- A `FOREIGN KEY` constraint is used to:
- A column or set of columns that uniquely identifies each row in a table is called a:
- What is the output of the following pseudo-code? ``` count = 0 for i from 1 to 3: for j from 1 to i: count = count + 1 ...
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)