What is difference between object and instance? If have a difference then, what is syntax to declare object and instance?
Answers
Answer:
Variables inside a class that are outside a method are called instance variables, but also creating an object of this class using the new keyword is also called an instance of class or less confusing an object of class.
In the example below we have created the Person class, and within that class we have an instance variable called 'personName' and an instance method called helloWorld(). Our variables and methods are called the 'instance members' of the class.
public class Person {
public class Person { private Name personName;
public class Person { private Name personName; public String helloWorld() {
public class Person { private Name personName; public String helloWorld() { return "Hello World";
public class Person { private Name personName; public String helloWorld() { return "Hello World"; }
public class Person { private Name personName; public String helloWorld() { return "Hello World"; }}
public class Person { private Name personName; public String helloWorld() { return "Hello World"; }}
public class Person { private Name personName; public String helloWorld() { return "Hello World"; }}For example, we can have hundreds and hundreds of different Person objects. Each Person object has its own instance of the personName object, each with its own value and i