Exercises

  1. Distinguish between class and object, member and field, primitive type and class type.

  2. Write a sample program that demonstrates the compiler will not let you access a private member from another class, but that you can write a public accessor function to set the value of a private field. (Compile the first part, compile and run the second part.)

  3. Write a class with a static block, some constructors, and instance initializers that print out the order in which these are executed.

  4. Describe why a setSomething() method is often given protected visibility.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.71.211