how would you answer the following question?
"Every variable in a Java program must have a ___________, which indentifies the kind of data that it will store."
would "declaration" be a valid answer to this question?
what would be the best answer?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
how would you answer the following question?
"Every variable in a Java program must have a ___________, which indentifies the kind of data that it will store."
would "declaration" be a valid answer to this question?
what would be the best answer?
type is the right word in my opinion
I guess the bigger question is, why do you think it would be declaration? The latter part of the question is a big hint itself - what identifies the kind of data a variable will store? See Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
Last edited by copeg; June 25th, 2012 at 04:45 PM.
I know what they all mean... A declaration requires just 2 things, a type, and a variable name. Pls answer what you think is correct.
pls post a response if you have an opinion.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
as far as I know a declaration does exactly that, it defines a variable's type and gives it a name.
If it was a test question, didn't the teacher tell you the correct answer? Did you put declaration down? Did it get marked right or wrong?
A declaration defines a variable's type and its name, but the question didn't ask about the name. It only asked about the kind of data stored in the variable.
To be honest the question could probably be answered either way. One of them is more specific though, so which is correct really depends on your teacher.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
the teacher said that declaration was wrong, but the way the question was worded i think that either one would be correct; declaring a variable defines it's type.
I have no problems with simple questions. But you've been given great resources and answers, so the rest is on you. I haven't talked down to you, but the burden is on you to define each, let us know what you think, why you think it, etc. Actually, I gave you pretty much a completely full answer, and you're still complaining. Why would people want to continue helping somebody like that?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Yes but the type is what defines what kind of data the variable will hold. The more specific answer is the more correct one.
It's like if the test question had been "where is Washington DC?" and you answered "on Earth" when the teacher was looking for "in America" or even "right between Maryland and Virginia". Was your answer technically wrong? No. Should you get full credit for it? No.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!