I'm going through a video tutorial and the instructor when saying certain words like "Instance, methods, object he selects the wrong one on the screen. Like for example when saying method he might select variable. So I want get this correct so I know what he is referring too.
I've added comments to the following code and want to know if they're all correct.
Question is:
1. Which one is a method?
2. Which is a function?
3. Which one is a object?
4. Which one is a instance of class?
5. Which one is a method type?
.
class Person {
// These are instance variables
String name;
int age;
// This is a method - aka function?
void sayHello() {
System.out.println("Hello there!");
}
}
public class App {
public static void main(String[] args) {
// Is `Person` a object? Or is `new Person()`; a object?
// `Person` in `Person person1` is a method type?
// `Person person1 = new Person();` is called instance of a class (Person class)?
Person person1 = new Person();
person1.name = "Joe Bloggs";
person1.age = 37;
person1.sayHello();
}
}