What is a Class in Java?
What is a Class in Java?
A class is a blueprint for an object. Just as an architect creates a
blueprint before the construction of a house, similarly in Java we need a class
before we construct an object or before we “instantiate” an object. In software
terms we call creation of an object from a class as instantiation.
Again, in the real world we see that before we construct a bridge or a ship we always create a blueprint. Then using that blueprint we can create hundreds of ships or hundreds of bridges. So this means that once you have the blueprint in place it is easier to construct objects and the same concept is used in Java. You will see that we create a class and then keep instantiating objects from it, as and when we like.
How would you instantiate an object from a class in Java, I mean in programming terms?
Use the “new” keyword and you have your object.
House houseObject = new House()
How about making your own class, a BRIDGE or a FRIDGE?
Again, in the real world we see that before we construct a bridge or a ship we always create a blueprint. Then using that blueprint we can create hundreds of ships or hundreds of bridges. So this means that once you have the blueprint in place it is easier to construct objects and the same concept is used in Java. You will see that we create a class and then keep instantiating objects from it, as and when we like.
How would you instantiate an object from a class in Java, I mean in programming terms?
Use the “new” keyword and you have your object.
House houseObject = new House()
How about making your own class, a BRIDGE or a FRIDGE?
What is Encapsulation?
What is Inheritance?
What are objects and classes?
http://ksimplified.com/?cat=1
Thanks for visiting................
No comments:
Post a Comment