0

why we create an object in java?

1st Feb 2017, 6:46 PM
Rahul Kumar
Rahul Kumar - avatar
2 ответов
+ 5
To manipulate it with flexibility.
1st Feb 2017, 6:57 PM
Mark Foxx
Mark Foxx - avatar
+ 1
Java is an object-oriented programming language. Objects provides good deal of advantages. Objects is the main calss in java. Every object has associated methods that you can call to perform desired task. For example, Cars. Car obj1 = new Car(); Car obj2 = new Car(); Here we have two objects that could potentially have name field, model field, year field, and so on. Now, no matter what car you have it will always have name, model number, and so on. Now considering that, you probably don't won't to code separately for each car as they have some same methods that you can use for all cars.Therefore, we use objects!
1st Feb 2017, 9:35 PM
Nimit Patel
Nimit Patel - avatar