University of Cambodia: Class and Object
University of Cambodia: Class and Object
1. Re-usability
It means reusing some facilities rather than building it again and again. This is done with the use of a class. We
can use it ‘n’ number of times as per our need.
2. Data Redundancy
This is a condition created at the place of data storage where the same piece of data is held in two separate
places. So the data redundancy is one of the greatest advantages of Class and Object. If a user wants a similar
functionality in multiple classes he/she can go ahead by writing common class definitions for the similar
functionalities and inherit them.
3. Code Maintenance
This feature is more of a necessity for any programming languages, it helps users from doing re-work in many
ways. It is always easy and time-saving to maintain and modify the existing codes with incorporating new
changes into it.
3.SCOPE OF STUDY
Create a Class
Create an Object
Class Attributes
CREATE A CLASS
In Java, an object is created from a class. We have already created the class named MyClass, so now we can use this
to create objects.
To create an object of MyClass, specify the class name, followed by the object name, and use the keyword new:
MULTIPLE OBJECT
Class:
Product
-ID
-Name
-Price
ABC Anchor
-ID Coca -ID
-Name -ID -Name
-Price -Name -Price
-Price
REFERENCE:
https://www.w3schools.com/java/java_oop.asp
https://www.w3schools.com/java/java_classes.asp
https://www.w3schools.com/java/java_class_attributes.asp
THANK YOU
FOR YOUR
ATTENTION