WORKING WITH JAVA OBJECTS
WORKING WITH JAVA OBJECTS
WORKING WITH JAVA OBJECTS – You need to define an object, its variables and members to represent any real world object in Java program for the implementation of this object in the program. This object can be a person, a place or a record of a database. A class is collection of data members and methods that are used to perform desired calculations and operations. Objects are the variable of type class. c In object-oriented programming , first the classes are defined then the objects are created and than the objects communicate with one another to accomplish the desired programming task. The object-oriented approach involve grouping of data and function into modular entities know as objects. You can group more than one object having similar attributes in program using the class concept. Classes are user-defined data types that contain objects of similar types. You can create any number of objects of a class. Following are the most important features of Object-Oriented Programming applied on the objects:
WORKING WITH JAVA OBJECTS – The technique of wrapping of data and methods into q single entity is termed as encapsulation. The data is accessed only by the methods which are encapsulated in the class. Encapsulation provide an interface between the data object and the Java program.
Inheritance provides a mechanism to acquire properties of one object of a class from the object of another class OOP uses the feature of inheritance for sharing the attributes and function between various classes.
Inheritance provides re-usability of codes in the program as it allows you to add additional features to an existing class without changing the class. The derived class inherits features such as variables and methods from a super class. This is the class from which a derived class inherits the variables and methods. A class that inherits the instance variable are created when the objects are instantiated and therefore are associated with the objects. Instance variables take different values for different objects. In Java programming, the feature of inheritance is divided into the following categories:
- Interface inheritance
For example , vehicles can be classified as motorised vehicles and non-motorised vehicles. Motorised vehicles include scooter and car and non-motorised vehicles include rickshaw and cycle. Scooter and car inherit the properties of motorised vehicles and rickshaw and cycle inherit the properties of non-motorised vehicles.
This example corresponds the feature of inheritance. Figure show the concept of inheritance.
- UP Police Constable New Practice Set in Hindi Download PDF 2018
- WEB TERMINOLOGY
- The Internet Architecture Board