Answer to Question #248250 in Java | JSP | JSF for Tege

Question #248250

Explain static variable, object variable, instance variable with example


1
Expert's answer
2021-10-08T23:50:36-0400

Static variable is a variable  that is declared with the static keyword in a class, but outside a method, constructor or a block.

Example of static variable is:

static int count=0;

An object variable is a container that holds a reference to a specific instance of a class.

Example of object variable is:

int x;

Instance variable are non-static variables which are defined in a class outside any method, constructor or a block. They belong to a class.

Example of instance variable:

public String pageName;


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS