The document contains a Java class named 'Demo' with private fields for age and name, along with getter and setter methods for these fields. The main method creates an instance of 'Demo', sets the age to 90 and the name to 'prerna', and then prints these values. There are also multiple instances of a 'Person' constructor that appears to have incorrect parameter types and is not properly integrated into the 'Demo' class.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views3 pages
Encapsulation
The document contains a Java class named 'Demo' with private fields for age and name, along with getter and setter methods for these fields. The main method creates an instance of 'Demo', sets the age to 90 and the name to 'prerna', and then prints these values. There are also multiple instances of a 'Person' constructor that appears to have incorrect parameter types and is not properly integrated into the 'Demo' class.