What does “private int a = 5” mean?
It means that a which is a type primitive int is only accessible within this class called…
What does the method signature “setA(int b) mean?
setA means it is a setter methods which allows other classes to set the value of a because it is a private variable.
The int b is the value that will be passed to the setA method. It will set the value of a to be that value b.
What is the toString() an example of?
toString() in this class is an example of overriding.
What is being created here. ExamQ2 ee = new ExamQ2(a)
An object of type ExamQ2 with a reference ee.
It is being passed a.
Discuss static methods and variables.
We can have static instance variables and static methods.
Both are associated with the class itself, not the object.
Therefore, statics can be accessed without instantiating the object.
Discuss a static variable
Like a global variable, but on a class by class basis. It is stored in the class. Static variables occur as a single copy in the class ( instance variables occur as multiple copies - one in each instance (object). eg., system.out is a static variable.
Discuss static methods.
Like a "global function" but on a class by class basis. There is no receiver because the static method is associated with the class, there is no object is associated with it, and therefore no receiver. You can think of it as the class being the receiver. Eg., System.arrayCopy()
Explain what makes GUI programs different to programs in which interaction is driven by a command line interface.
Eg., compare navigating a directory vs clicking on something
What is an interface?
ie., shape interface, rectangle implements interface
Shape rectangle = new Rectangle (2,4)
What are the advantages of interfaces?
What are the advantages of interfaces to the programmer?
What are the disadvatnages of interfaces to the programmer?
What is the difference between inheritance and interfaces?