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
- A system has a page size of 2KB. A logical address is 32 bits. How many bits are used for the page offset?
- Consider the following C code: #include #include int main() { char str1[] = "Hello"; char str2[] = {'W', 'o', 'r', 'l', 'd', '\0', 'X'};...
- Which of the following best describes the primary purpose of inheritance in OOP?
- Which of the following statements about the UNION operator in SQL is correct?
- Which of these is a feature of cloud elasticity?
- Which password storage technique is considered most secure against rainbow table attacks?
- Which of the following statements about mesh topology is correct?
- Which of the following protocol should be used for those websites which need login credentials for sending the data?
- What is the primary purpose of the ALOHA protocol in networking?
- CPU generated memory request always refer the :
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