[Logo]
Forums Register Login
Test question
Which statements are correct? (edit: i pasted in different question earlier, need to be more careful proof-reading)
I did not like any of the answer choices to this question and thought correct answer would have 1, 2, and 4.


Here is the question:
Which statements are true?

Declaring a variable does not create an object.
In Java, no variable can ever hold an object.
You can create an object in Java by declaring it.
A variable can only hold a reference to an object.

Choose one answer.
a. All of the above
b. 2, 3, 4
c. 2, 4
d. 1, 3, 4

(Instructor)
The right answer is (a).


Thank you
Why not #3?
Always tell us where the question is from. Those are poorly-worded questions, with vague answers.
 
marc weber wrote:Why not #3?

nothing, I posted wrong question, please see edit above
 
Campbell Ritchie wrote:Always tell us where the question is from. Those are poorly-worded questions, with vague answers.

This came from the recent final exam for an online Programming I course offered by a yet unaccredited school.
The course used math.hws.edu/javanotes as the text.
edit: just read the exam question copyright notice, the school endeavors to offer its materials under creative commons license
 
Ii Mechnikov wrote:... I did not like any of the answer choices to this question and thought correct answer would have 1, 2, and 4.

Here is the question:
Which statements are true?

Declaring a variable does not create an object.
In Java, no variable can ever hold an object.
You can create an object in Java by declaring it.
A variable can only hold a reference to an object.

Choose one answer.
a. All of the above
b. 2, 3, 4
c. 2, 4
d. 1, 3, 4

(Instructor)
The right answer is (a)...

I agree with Campbell in saying these questions are vague and poorly worded.

That said, I agree with 1 and 2.

But I would say number 3 is false. You can create a new object and assign its reference on the same line as the declaration, but the declaration itself does not create an object (as number 1 seems to say).

I would also say number 4 is false, because a variable can also hold a primitive value.
 
marc weber wrote:
Ii Mechnikov wrote:... I did not like any of the answer choices to this question and thought correct answer would have 1, 2, and 4.

Here is the question:
Which statements are true?

Declaring a variable does not create an object.
In Java, no variable can ever hold an object.
You can create an object in Java by declaring it.
A variable can only hold a reference to an object.

Choose one answer.
a. All of the above
b. 2, 3, 4
c. 2, 4
d. 1, 3, 4

(Instructor)
The right answer is (a)...

I agree with Campbell in saying these questions are vague and poorly worded.

That said, I agree with 1 and 2.

But I would say number 3 is false. You can create a new object and assign its reference on the same line as the declaration, but the declaration itself does not create an object (as number 1 seems to say).

I would also say number 4 is false, because a variable can also hold a primitive value.

Thank you for replying.
4 is ambiguous, it would be correct if it specified 'in addition to primitive values'.
I was wondering if I am missing something regarding 1 and 3. Am I correct to think that 1 and 3 exclude each other?
 
Ii Mechnikov wrote:... I was wondering if I am missing something regarding 1 and 3. Am I correct to think that 1 and 3 exclude each other?

Your thinking is correct. You shouldn't have to guess, but if your instructor says number 3 is true, I think he/she is trying to say you can do this...

...instead of this...

But as it's worded, I say number 3 is false. Simply declaring an object does not create one. (Note that null is a special reference type -- not an object. So default initialization does not create an object.)
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Dec 15, 2017 03:21:24.