Amazon.com Widgets Chapter 7 Quiz
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 19, 2014, 05:55:01 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Study Group
| |-+  Objective-C Quizzes
| | |-+  Chapter 7 - More on Classes
| | | |-+  Chapter 7 Quiz
Pages: [1]   Go Down
Print
Author Topic: Chapter 7 Quiz  (Read 9062 times)
skochan
Administrator
Hero Member
*****
Posts: 3114







« on: April 02, 2009, 07:43:00 PM »

A 15-question quiz on Chapter7.

Chapter 7 Quiz

Cheers,

Steve Kochan
Logged
enigmakv
Newbie
*
Posts: 37







« Reply #1 on: September 15, 2009, 12:14:48 AM »

Steve,

I think the third choice for quiz question six might be misstated.  I answered the question correctly, but I think the third choice said "interface" section but meant "implementation".  It disappeared too quickly so I might be wrong.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







« Reply #2 on: September 15, 2009, 04:42:30 AM »

The questions are shuffled each time, but I found it.  Thanks!

Cheers,

Steve
Logged
Gus
Newbie
*
Posts: 2






« Reply #3 on: December 16, 2009, 04:18:08 PM »

Hi Steve,

I can´t access the quiz; when i click on the link "Chapter 7 Quiz" it takes me to another page with 4 rows; c1, c2, c3, and c4 but when i click on either one the message

incorrect!
undefined

appears.

What to do?

Just signed up, first post!

Cheers
Logged
happyzhb
Administrator
Newbie
*****
Posts: 47


Email




« Reply #4 on: December 17, 2009, 08:10:59 AM »

Try to use Fireforx or safari instead of IE.  Smiley
Logged
Gus
Newbie
*
Posts: 2






« Reply #5 on: December 18, 2009, 11:07:29 AM »

Yep, I was just about to post that Firefox solved the problem - what a glitch for IE8!

Many thanks.
Logged
tslining
Newbie
*
Posts: 5


Email




« Reply #6 on: March 09, 2010, 09:47:05 AM »

If width is an instance variable, then this line in the interface section

  @property int width;

and this in the implementation section

  @synthesize width;

will

Wouldn't the answer to this one be all of the above since it will generate a getter method called width and a setter method called setwidth:  This is according to what you have written on page 140 of the text.  What am I missing on this one? Is it because it should be setWidth: ?
« Last Edit: March 09, 2010, 10:21:25 AM by tslining » Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







« Reply #7 on: March 09, 2010, 03:15:13 PM »

Quote
What am I missing on this one? Is it because it should be setWidth: ?

That's it!

Cheers,

Steve
Logged
MarkReid
Full Member
***
Posts: 173






« Reply #8 on: March 17, 2010, 07:34:13 AM »

In the question which asks

An automatic local variable has no default initial value

Does that just mean a normally declared local variable?
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







« Reply #9 on: March 17, 2010, 08:52:08 AM »

Yes!
Logged
godwheel
Newbie
*
Posts: 19







« Reply #10 on: May 20, 2010, 02:19:22 PM »

I figure I post the questions and explanations for each answer to the quiz.  If anyone wants to chime in as to if my answer is accurate, please feel free to EDIT this post. Smiley

Thanks!



QUESTION: 1
Given that this statement is executed inside a method

Fraction *f =  [[Fraction alloc] init];

what is true when the method returns?
(1) The variable f is destroyed
(2) The allocated Fraction object is deallocated
(3) Both f and the allocated Fraction are destroyed
(4) None of the above is true

ANSWER:
(1)

EXPLANATION:
*f is a local variable set inside a method. Local variables are destroyed after the method is executed.



QUESTION: 2
A method called print:: takes three arguments.

(1) TRUE
(2) FALSE

ANSWER:
(2)

EXPLANATION:
There are two : so the method takes two arguments.



QUESTION: 3
Sending a message to self has the effect of sending the message to the receiver of the current message.

(1) TRUE
(2) FALSE

ANSWER:
(1)

EXPLANATION:
self sends a message to the receiver of the current message



QUESTION: 4
Sending a message to self has the effect of sending the message to the receiver of the current message.

(1) TRUE
(2) FALSE

ANSWER:
(1)

EXPLANATION:
self sends a message to the receiver of the current message



QUESTION: 5
What is true about this local variable counter if this statement is executed inside a method?
int counter = 0;

(1) Its value will be set to 0 every time the method is called
(2) Its value will be set to 0 only once when the program begins execution
(3) Its value will be retained through method calls
(4) None of the above

ANSWER:
(1)

EXPLANATION:
when a variable is declared inside a method, each time the method is called the value is set



QUESTION: 6
What is true about the local variable counter if this statement is executed inside a method?


static int counter = 0;
(1) Its value will be set to 0 every time the method is called
(2) Its value will be set to 0 only once when the program begins execution
(3) Its value will not be retained through method calls
(4) None of the above

ANSWER:
(2)

EXPLANATION:
static variables are automatically set once when the program begins execution



QUESTION: 7
A static variable will retain its value from one method call to the next.

(1)True
(2)False

ANSWER:
(2)

EXPLANATION:
None needed



QUESTION: 7
A static local variable has no default initial value.

(1) True
(2) False

ANSWER:
(2)

EXPLANATION:
None needed


QUESTION: 8
If width is an instance variable, then this line in the interface section

  @property int width;

and this in the implementation section

  @synthesize width;

will
(1) generate a getter method called width
(2) generate a setter method called setwidth:
(3) all of the above

ANSWER:
(1)

EXPLANATION:
This is a trick question, the @synthesize will generate a setter method called setWidth (notice the uppercase W).



QUESTION: 9
What can you say about the indicated statement?

Fraction *f =
  [[Fraction alloc] init], *g;
  ...
g = f;
[g release]; <==
 ...
 
(1) It's invalid and will cause the program to crash
(2) It could be replaced by [f release] with the same effect
(3) It should be followed by [f release] to avoid memory leaks
(4) None of the above

ANSWER
(2)

EXPLANATION
The f replaces g.



QUESTION: 10
An automatic local variable has no default initial value

(1) True
(2) False

ANSWER:
(1)

EXPLANATION:
Local variables have no default initial value, so they must be set before using them.



QUESTION: 11
Advantages of separating a class definition into separate interface and implementation files are
 
(1) Someone using the class doesn't have to get direct access to the code for the methods
(2) The code for the methods can be stored in a system library
(3) The interface section suffices to tell the compiler the class' methods and instance variables
(4) All of the above

ANSWER
(4)

EXPLANATION
None needed



QUESTION: 12
The method names print and print: refer to two different methods.

(1) True
(2) False

ANSWER:
(1)

EXPLANATION:
the method print does not expect in an argument while the method print: does



QUESTION: 13
Given the following method declaration in the interface section, what can you say about area?
-(Rectangle *) area;
 
(1) It takes no arguments
(2) It returns a Rectangle object
(3) A corresponding method definition should appear in the implementation section
(4) All of the above

ANSWER
(4)

EXPLANATION
None needed


QUESTION: 14
Can you send a message to self  from inside main?

(1) True
(2) False

ANSWER:
(2)

EXPLANATION:
no, self only refers to the object that is the receive of the current method



QUESTION: 15
Given an object with an instance variable called numerator and synthesized accessor methods the following two lines of code achieve the same purpose:

fract.numerator = 10;
[fract setNumerator: 10];

(1) TRUE
(2) FALSE

ANSWER:
(1)

EXPLANATION:
None needed
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







« Reply #11 on: May 21, 2010, 06:12:08 AM »

Hi,

You have two question 7s.   The first one is TRUE, by the way.

Cheers,

Steve Kochan
Logged
afterDark
Global Moderator
Full Member
*****
Posts: 126






« Reply #12 on: November 18, 2012, 03:57:34 PM »

there are some memory management questions in the test, I suppose for the 3rd edition of the book. Maybe it is a good idea to mark those questions as 'skip this question if you have the 4th edition of the book' as a quick resolution.
Logged

I am just an amateur with Objective-C, don't let the moderator label fool you. Working my way through the book slowly.
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.