Instantiation

  • Basically when you create a class, you have to create the variables, which are the class attributes. And then in constructors, you set the value of those variables (attributes) to something. So you define them.

  • Below are three different constructors. The first one has no formal parameters because it is just a basic default employee. When you make an object using this, the values will be all the default values. The second two can be used to create actual employees with personalized data:

notes6

Void method

Methods define the behaviors for all objects of a class and consist of a set of instructions for executing the behavior. Void methods don’t return anything. Example: notes9

Void method with parameters These are methods that take in some parameter, or input but doesn’t return anything

Overloading: Having multiple methods with the same name, but different parameters. notes10

Non-void Methods

The value that is returned from a method, you need to specify the type that is being returned in the method signature. Let’s say you return something to main, main now has access to that returned value. Remember, return does not mean print. You would need to specifically say print the return value if you want it to be displayed.