Complete the code to declare a private integer variable named age.
class Person { [1] int age; }
The keyword private makes the variable accessible only within the class.
Complete the code to create a private String variable called name.
class Student { [1] String name; }
Use private to keep the variable accessible only inside the class.
Fix the error in the code by choosing the correct access modifier for the data member.
class Car { [1] String model; }
The data member should be private to follow encapsulation principles.
Fill both blanks to declare two private data members: an int id and a String name.
class Employee { [1] int id; [2] String name; }
Both variables should be declared private to keep them hidden from outside access.
Fill all three blanks to declare private data members: a String title, an int pages, and a double price.
class Book { [1] String title; [2] int pages; [3] double price; }
All three data members should be private to protect the data inside the class.