OCP EXAM OBJECTIVES COVERED IN THIS CHAPTER:
- Creating and Using Methods
- Create methods and constructors with arguments and return values
- Create and invoke overloaded methods
- Apply the static keyword to methods and fields
- Applying Encapsulation
- Apply access modifiers
- Apply encapsulation principles to a class
In previous chapters, you learned how to use methods without examining them in detail. In this chapter, you’ll explore methods in depth, including overloading. This chapter discusses instance variables, access modifiers, and encapsulation.
Every interesting Java program we’ve seen has had a main() method. You can write other methods, too. For example, you can write a basic method ...