1. variables defined with default visibility can be seen by code in classes in the same package.
2. Every class must have a main method
3. Statically declared variables are instance variables
4. All objects use the same value for class variables
5. Set methods require a parameter
6. Primitive data types work well with comparison operators
7. A Do-while loop evaluates the conditions before the body is run
8. For loops are good when you need to repeat the body of the loop is run
9. Using == with objects will compare the values of the objects
10. The order of parameter in a method call are not important

I am studying for my java exam so i need to sure of the above

Comments
Hope you fail your Java exams!

Good luck on your exam.
If you have any specific programming problems, post the code with your questions.

Edited 5 Years Ago by NormR1: n/a

well ...
are you studying it, or are you following a course which expects you to study it?

these questions handle the basics of the basics ... if you get this ten questions as a test, and don't pass ... well ... no offence, but if you don't get at least 80%, you may as well consider it a fail.

don't just read the question, think about the subject, how it is used, and how it is (should be) implemented.

as JamesCherrill suggested: post your answers here. or even better, post your answers and the reason why you think that's the answer. sure, we can give you a true/false, or even correct your true/false, but you are better served if we correct your knowledge about why it's true or false

Comments
Agree
Good advice

sorry here are my answer
1. true
2. true
3. false
4. true
5. true
6. true
7. true
8. true
9. true
10. false

well ...
there are some correct answers in there. but there are also some mistakes.
can you add for each 'true' or 'false' the reason you think it's true or false?

I have to say, some of these questions are really not very good ones at all.
There are some factual questions which are either true or false, but what about these?

4. All objects use the same value for class variables
5. Set methods require a parameter
6. Primitive data types work well with comparison operators

#4 seems obviously false - but when I think about it, it seems to depend on what assumptions I make about what it means. Does this mean "all objects of a particular class have the same values for their class variables"? Obviously false. Does it mean "all objects of a class start out with the same class variable values"? Depends on how they're intialized, I guess. Does it mean "all objects follow the same rules for intializing their class variables"? Well, true. Which is meant? I don't know.

#5 seems obviously true, but then on further consideration I could easily write a set method that didn't require a parameter. I might overload the setFoo() method to provide a default - that would require no parameter. I might write it to query some other object for its value - that would require no parameter. On the other hand, if I say false, I'm sure to get the question wrong, because clearly the answer the teacher wants is "true".

#6 is just dumb. Primitive types don't work "well" or "poorly" with comparison operators - comparison operators work on primitive types, and with the exception of ==, they don't work on objects. What could this question mean?

So I can understand being confused by those ones - it's quite possible that a knowledgeable Java programmer would get #4 and #5 wrong, unless they were gaming the test and knew which sort of answer the teacher wanted, and #6 is just a bad question.

The others (some of which you got wrong) are simple questions about the Java language, and easily answered with a little research.

Hi Jon. Oracle define "class variable" to be a synonym for static variable

Um, yeah. Brain fail - I was thinking "instance variable" for some reason. Okay, yes, I'm wrong on that one. Thanks.

Um, yeah. Brain fail - I was thinking "instance variable" for some reason. Okay, yes, I'm wrong on that one. Thanks.

It is still false, however, as it should be "all objects/instances created from the same classloader". Instances created from one classloader will not have the same reference value as those created using another classloader. They may have the same "content value", depending on how it is defined, of course, but they will not have the same reference value.

Edited 5 Years Ago by masijade: typos

This article has been dead for over six months. Start a new discussion instead.