Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Test question

 
Igor Mechnikov
Ranch Hand
Posts: 100
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not #3?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50212
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always tell us where the question is from. Those are poorly-worded questions, with vague answers.
 
Igor Mechnikov
Ranch Hand
Posts: 100
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
marc weber wrote:Why not #3?

nothing, I posted wrong question, please see edit above
 
Igor Mechnikov
Ranch Hand
Posts: 100
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Igor Mechnikov
Ranch Hand
Posts: 100
Chrome Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic