Java is an object-oriented language. “Object-oriented” is a term that has become so commonly used as to have practically no concrete meaning. This chapter explains just what “object-oriented” means for Java. It covers:
- Classes and objects in Java
- Creating objects
- Garbage collection to free up unused objects
- The difference between class (or static) variables and instance variables, and the difference between class (or static) methods and instance methods
- Extending a class to create a subclass
- Overriding class methods and dynamic method lookup
- Abstract classes
- Interface types and their implementation by classes
If you are a C++ programmer, or have other object-oriented programming experience, many of the concepts in this list should be familiar to you. If you do not have object-oriented experience, don’t fear: This chapter assumes no knowledge of object-oriented concepts.
We saw in the last chapter that close analogies can be drawn between Java and C. Unfortunately for C++ programmers, the same is not true for Java and C++. Java uses object-oriented programming concepts that are familiar to C++ programmers, and it even borrows from C++ syntax in a number of places, but the analogies between Java and C++ are not nearly as strong as those between Java and C. [1] C++ programmers may have an easier time with this chapter than C programmers will, but they should still read it carefully and try not to form preconceptions about Java based on their knowledge of C++.
[1] As we’ll see, Java supports garbage collection and dynamic method lookup. This actually makes it a closer relative, beneath its layer of C-like syntax, to languages like Smalltalk than to C++.
Read more on Introduction to Classes and Objects in Java







03 Dec 2011
Posted by Aals 

