Chapter 2
Q1) What should you do if all this talk of life cycles, classes, and methods is a bit confusing?
A) Don't worry about them. Understanding comes a bit at a time, and if they are not entirely clear at this stage, it will not hold you back from thoroughly learning Java, and all will become clearer as we progress.
Q2) What exactly is a Java class?
A) Classes are a fundamental building block of Java programs. They are like containers for our Java code, and we can even use other people's classes to simplify the programs we write, even without seeing or understanding the code contained within those classes.
Q3) What is the difference between a method and a class?
A) Methods are contained within classes and represent the specific functionality of the class, like another container within a container. As an example from a game, we might have a Tank
class with shoot
, drive
, and selfDestruct
methods. We can use a class and its methods by making our own class, as we will in Chapter 6...