Exercises
-
Distinguish between class and object, member and field, primitive type and class type.
-
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.)
-
Write a class with a static block, some constructors, and instance initializers that print out the order in which these are executed.
-
Describe why a
setSomething()
method is often givenprotected
visibility.
Get Just Java™ 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.