Which class is super class of every class

What is difference between declaring variable and defining variable

Answer:
Declaring variable : It means when we create variable or object reference without providing any assignment of the value or object respectively called declaration.

Defining or Initializing variable : When we assign value or object to to the variable.

Example :

import java.util.ArrayList;
import java.util.List;

public class DeclareVariable {

	public static void main(String[] args) {

		int i; // Declaration
		List<String> list; // Declaration

		i = 10; // Definition or Initialization
		list = new ArrayList<String>(); // Definition or Initialization

	}

}

 

Leave a Reply

Your email address will not be published. Required fields are marked *