Question
Consider the following Java code: public class Product { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public String getName() { return name; } public void setPrice(double newPrice) { if (newPrice > 0) { this.price = newPrice; } else { System.out.println("Price cannot be negative."); } } } This code demonstrates encapsulation by:
More IT Operating System Questions
- What is the primary use of the printf function in C/C++ programming?
- A network admin wants a firewall that automatically allows return traffic for an outbound connection without requiring a separate explicit inbound rule, wh...
- What does the term 'elasticity' refer to in the context of cloud computing?
- Every host computer on the internet has a (n) :
- Consider the following Java code: class Animal { String type = "Generic Animal"; void eat() { System.out.println("Animal eats food."); ...
- Which of the following is a characteristic of an intelligent agent?
- Which of the following is a property of an admissible heuristic in A* search?
- In a data analysis application, a hash table is used to store key-value pairs for fast lookups. What is the primary goal of a good hash function?
- Length of IPv6 address is _____ bits.
- A file has permissions represented as -rwxr-xr--. What is the equivalent numeric (octal) representation of these permissions in Linux?
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)