answersLogoWhite

0


Best Answer

It is because, the keywords are defined in the java language for a specific purpose. If we start declaring variables with the same name, the compiler would not know if you are trying to use a variable are trying to tell it to perform an action and hence keywords cannot be used as a variable name.

User Avatar

Wiki User

βˆ™ 14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 15y ago

The reason is simply because then Java would have no idea how to determine which was which. A compiler/linker/interpreter should ideally be deterministic, which is to say that it should never have to guess at what a word means.

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 10y ago

Presumably they would confuse the compiler. And there would be ambiguous cases where even a human wouldn't know what was meant.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why can't we use a keyword as a variable name?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the 6 ways to use this keyword?

"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.The following are different ways to use java this keyword1) Using with instance variable2) Using with Constructor3) Pass / Return current instanceUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with ConstructorUsing this keyword inside constructor like followingthis("Sony", 20); it will call the constructor having same parameter


What is the purpose of transient keyword in Java?

A variable which is declared as transient will not be serialized. This means that when you use an ObjectOutputStream to store the current state of a class, anything labeled as transient will be skipped over.A common use of this keyword is to ensure that sensitive user information (usernames, passwords, etc.) is not accidentally saved to a file.


What is the think-central go-keyword?

Depends on the textbook you use. If you dont specify chapter, section, section name, and book title i cant help you.


Which keyword is used to declare a class?

There is no keyword for it. You can use a variable of 1 class in another only id the other class is derived from the 1st class.Although you can use the variable of an object of a class in another class using object.variable


Which variable is use for create for read only variable?

That really depends on the language. Some languages have "constants" separate from "variables"; in Java, for example, the "final" keyword is used to have a variable that can't be changed once it is assigned a value.

Related questions

Can you declears static in a local variable in a method in java?

we cannot use the staic keyword inside the method... But we can use the final keyword inside the method....


What are the 6 ways to use this keyword?

"Java This keyword" is a reference to the current object, it is very helpful when you need to refer an instance of a particular Object from its available methods or using it's constructor, also "this" keyword helps us to avoid naming conflicts.The following are different ways to use java this keyword1) Using with instance variable2) Using with Constructor3) Pass / Return current instanceUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with instance variableUsing this keyword inside a method or constructor it will use instance variable instead of local variable, in the absence of this keyword it will use local variableUsing with ConstructorUsing this keyword inside constructor like followingthis("Sony", 20); it will call the constructor having same parameter


How will you defined variavble in vb script?

To define a variable in VBScript, you use the keyword "Dim" followed by the name of the variable. You can name the variable any string so long as itBegins with a letterDoes not contain a period (.)Is not longer than 255 charactersSo "tom" is a valid variable name, but "tom.d" is not.To assign value to the variable, you use the assignment operator (=)Dim coolWebSite = "Answers.com"The variable "coolWebSite" will now contain the string "Answers.com"


What is the purpose of transient keyword in Java?

A variable which is declared as transient will not be serialized. This means that when you use an ObjectOutputStream to store the current state of a class, anything labeled as transient will be skipped over.A common use of this keyword is to ensure that sensitive user information (usernames, passwords, etc.) is not accidentally saved to a file.


What is the think-central go-keyword?

Depends on the textbook you use. If you dont specify chapter, section, section name, and book title i cant help you.


What is one keyword you could use to describe a constant variable?

The "Constant" or "Control"I can't think of much else...


Which keyword is used to declare a class?

There is no keyword for it. You can use a variable of 1 class in another only id the other class is derived from the 1st class.Although you can use the variable of an object of a class in another class using object.variable


Which variable is use for create for read only variable?

That really depends on the language. Some languages have "constants" separate from "variables"; in Java, for example, the "final" keyword is used to have a variable that can't be changed once it is assigned a value.


Why a static member method can access only static members in java?

Because, the keyword static signifies the fact that the method or variable that is qualified using the static keyword is not attached to any object of the class. Therefore we cannot instantiate the class and use the object to reference to access it. The only option we have is to use the class name to directly access them


How do you create static variables in PHP?

Use the "static" keyword to declare a static variable within a function like shown below. <?php function fun() { static $variable; static $another_variable = ''; } ?>


What keyword is used to declare a named constant?

Constant in Java refers to a fixed value that doesn’t change during the execution of a program. The value of constants appears right in a program. It is also known as Literals. We use the constants to create values that assign to variables. Constants can make our program easy to read and understood by others. Java does not directly support the constant. To define a variable as a constant, We use the β€œStatic” and β€œFinal” Keywords before declaring a variable. Hope this helps. Thank you


What is the program to use the super and final keyword in java?

Many programs use those keywords.super refers to the direct superclass of the class referencing itfinal declares a variable or class unchangable