answersLogoWhite

0


Best Answer

Depending on the language you are using the default of an instance variable can be '0', 0, null, empty, '', or have a random number.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Default value for instance variable
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Computer Science

How do you declare variables and constants.explain with example?

Depends on the programming language you are using. I will give two simple examples. In Command Prompt and when creating a batch file, you declare a variable by entering the "set" command. You can use different switches to change the type of variable you are declaring. /p makes the variable able to accept user input. /a makes the variable a numerical expression. In Python, you declare a variable just by stating the name of the variable and its value. x = value.


What VLANs are allowed across a trunk when the range of allowed VLANs is set to the default value?

all VLANsThe default is to allow all VLANs through the trunking ports.


What is the localhost 3306 use?

SYNTAX fo MySQL connectivity: MySQL( server name,username,password); Parameter Description server name : >Optional. >Specifies the server to connect to. >Default value is "localhost:3306" username : >Optional. >Specifies the username to log in with. >Default value is the name of the user that owns the server process password : >Optional. >Specifies the password to log in with. Default is ""


What is a volatile keyword How it helps in the embedded perspective?

Compiler dont know the value of the variable, That variable can set at any time in the process running. ex interrupt or any bit set.


A constant that multiplies a variable?

A constant that multiplies a variable is no longer a constant. By its very definition, a constant is something that can never be different. The result of variable multiplication is thus a variable, not a constant.I would say that the above answer is not necessarily true. The common equation for the area of a circle is: area = pi * r2The fact that you are multiplying the mathematical constant pi by a variable does not change the value of pi.Agree with the second answer. Jsut to add, a constant that multplies a variable is called a coefficient.

Related questions

What is the function of default values in java?

Default values are available for any class or instance variable. If you do not specify a value for a class or instance variable the JVM will provide a default value that will ensure that the system does not end up with any unexpected errors because you used a variable that was not initialized. Ex: Public class Test { int I; } In the above class we have just declared an instance variable called 'I' but we haven't associated any value to it. The JVM automatically assigns 0 as the default value to this variable.


What is the initial value of a numeric variable?

When we talk about instance variables, the default initial value for a numeric variable is always '0'. Any other variable in your code must be initialized before you can use it. public class MyClass{ public int x; // 0 by default public float y: // 0 by default public MyClass{ int z; z++; // Error 'z' don't have a default value } }


What does a Java Boolean type variable declared but not yet initialized contain when its class is instanciated?

If it is a class or instance variable, it gets the default value of false. If it is a local variable (inside a method), it doesn't have a value until you explicitly set one.


What is default value of Boolean type variable?

False will be the default value of the boolean datatype in java


What is the initial value of (-1-17) and (-3-15)?

When we talk about instance variables, the default initial value for a numeric variable is always '0'. Any other variable in your code must be initialized before you can use it. public class MyClass{ public int x; // 0 by default public float y: // 0 by default public MyClass{ int z; z++; // Error 'z' don't have a default value } }


What is static variable in the class in cpp?

Static member variables of a class are variables that are local to the class within which they are declared. That is, each instance of the class (each object) shares the same common member variable. Changing that variable's value in one instance will change it for all instances. Contrast with a non-static member variable where each instance of the class has its own independent variable, scoped to the object itself (not the class of object).


What value is assigned to extern variable?

Default initial value of extern integral type variable is zero otherwise null.


What happens if you don't initialize an instance variable of any of the primitive type in java?

Java by default initializes it to the default value for that primitive type. Thus an int will be initialized to 0(zero), a Boolean will be initialized to false.


What is the by default value of globally declaration variable?

int, float: 0 pointer: NULL


What is the default initial value for all numeric types?

If they are instance variables the default initial value is 0. If they are method local variables, they are null and must be initialized to some value before they are used


What does instance field mean in Java?

Fields defined without the "static" keyword.Their value is unique to each instance (object) of a class.AnswerInstance variable is a variable declared within the class for which every object of the class has its own value.


What is the difference between instantiation and initialization in C plus plus?

Instantiation is creating the instance of the variable/object . While Initialization is to provide the variable with some value. int i; // i is an instance of an integer i=10; //initialised with the value 10