Chapter 3. Methods and encapsulation

 

3.1. Scope of variables

3.1.1. Local variables

3.1.2. Method parameters

3.1.3. Instance variables

3.1.4. Class variables

3.1.5. Overlapping variable scopes

3.2. Object’s life cycle

3.2.1. An object is born

3.2.2. Object is accessible

3.2.3. Object is inaccessible

3.2.4. Garbage collection

3.3. Create methods with arguments and return values

3.3.1. Return type of a method

3.3.2. Method parameters

3.3.3. Return statement

3.4. Create an overloaded method

3.4.2. Return type

3.4.3. Access level

3.5. Constructors of a class

3.5.1. User-defined constructors

3.5.2. Default constructor

3.5.3. Overloaded constructors

3.6. Accessing object fields

3.6.1. What is an object field?

3.6.2. Read and write object fields

3.6.3. Calling methods on objects

3.7. Apply encapsulation principles to a class

3.7.1. Need for encapsulation

3.7.2. Apply encapsulation

3.8. Passing objects and primitives to methods

3.8.1. Passing primitives to methods

3.8.2. Passing object references to methods

3.9. Summary

3.10. Review notes

3.11. Sample exam questions

3.12. Answers to sample exam questions

sitemap