Friday, September 23, 2016
Java - Classes and Objects
To lean Java, we should first know that it is an object-oriented programming language. The concepts of objects and classes are very important, because they are fundamental knowledge we are supposed to understand before we do some more complex programming.
As we began to learn Java several weeks ago, we have already been relatively familiar with Java classes. The accurate definition of a class is that a class is a software blueprint for implementing objects of a given type. For example, let's create a Dog class.
public class Dog { double age; String color; }
Class defines a new type of data, and in this case, Dog is our new data type. "Dog" will be used to declare objects of Dog.
Then, we should created some objects. Object refers to a particular instance of a class where the object can be a combination of variables, functions, and data structures. An object is characterized by its state and behavior. For example, a dog object has states described by its age, color, sex, and so on. It also has behavior, like jumping, running, etc. In fact, an object corresponds to some real-world object represented by the program.
---------------------------------------------------------------------------------
Writing References:
1.https://en.wikipedia.org/wiki/Object_(computer_science)
2.http://www.c4learn.com/java/java-classes-basics/
3.Barron's AP Computer Science A
Picture References:
1.http://img.c4learn.com/2012/03/Creating-Object-of-Class-in-Java-Programmming-Language.png
2.http://cdn2-www.dogtime.com/assets/uploads/gallery/labrador-retriever-dog-breed-pictures/labrador-retriever-dog-pictures-3.jpg
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment