Welcome! Log In Create A New Profile

Advanced

Mock exam paper answers ?

Posted by esckay 
Announcements Last Post
Announcement myUnisa availability 21 to 24 March 2019 03/17/2019 02:24PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Mock exam paper answers ?
October 30, 2007 12:20PM
Hi,

Does anyone have answers for the mock exam paper (103) we received ? If you do, I would really appreciate a copy.

You can mail it to esckays@gmail.com

Thanks.
avatar Re: Mock exam paper answers ?
October 30, 2007 12:31PM
Hi

Please can you send me a copy as well
trishennaidoo@gmail.com

Thanks
Re: Mock exam paper answers ?
October 30, 2007 12:36PM
Re: Mock exam paper answers ?
October 30, 2007 12:48PM
Here is what I have so far, but this was done very quickly and I not sure whether it is correct.

Section A
1. 3
2. 3
3. 3
4. 2
5. 2
Section B
1.
2.a Method overiding:
void g() method in ClassY
Dynamic binding:
System.println(xObjects[0])
dynamically invoking the toString() method in the class
2.b {m = 0, n = 0}
{m = 0, n = 0}
Now in ClassY.g()
Now in ClassY.g()
Now in ClassX.g()
3. Has to do with deep vs shallow copy
4. /**
* @pre = size() > 0
* @post = size()@pre + 1
* @result = element(0)@pre
*/

Something like that ... please let me know if you agree or disagree.

Thanks.
Re: Mock exam paper answers ?
October 30, 2007 01:56PM
My answers for section A are:
1. 3
2. 3
3. 4 (won't result in compilation error, if toString() not overridden then will print out memory address)
4. 1 (text book bottom of page 142)
5. 2

Section B:
1. The composite design pattern is used when objects form a hierarchy or part-whole relationship and there is a need to treat individual objects and composite objects in a uniform way. The participants in this pattern are Client (accessing components), Component (abstraction of component), Composite (composes other components) and Leaf (lowest level component). The decorator pattern is used to dynamically add functionality to classes at runtime without needing subclassing. The participants are Component (abstraction) , ConcreteComponent (concrete implementation of component), Decorator (subclass of Component, maintains reference to concrete instance of Component and invokes operations on that object) and ConcreteDecorator (subclasses Decorator, invokes base method invoking Component operations and adds its own additional operations).

2a. Method overriding is when a method with the same signature and return type that exists in a base class is redefined in a descendant class. This results in the descendant implementation being invoked when the call is made on a variable of that type. To invoke the implementation in the base from within the descendant, use super(params). In this program, method overriding is found in ClassY with the function void g().
Dynamic binding refers to the selection of implementation of a method invocation being based on the class of the variable at runtime rather than the defined type of the variable at compile time. In this program, the array contains objects of type ClassX but the first item is in effect of type ClassY which means any method invoked on the first element in the array will invoke the method in ClassY (if overriden).

2b.
{m = 0, n = 0}
{m = 0, n = 0}
Now in ClassY.g()
Now in ClassY.g()
Now in ClassX.f()

3 The first statement infers that the object being cloned must not be the same object as the one that is returned by the clone operation (i.e. the objects must be identical). The second statement means that the state of the object returned by the clone operation must be the same as the state of the object being cloned (i.e. the objects must be equal). To facilitate meeting these demands must firstly ensure that must not use the new() operator on the object within the clone method but rather use super.clone() and typecast to the required type and secondly, each of the fields in the object must be copied to the cloned object (primitive types can be copied directly, reference types must be copied using clone() on those objects). A template of the clone method (assuming object being cloned is of type Test and reference field is of type Fruit):
public Object clone() throws CloneNotSupportedException{
  Test clonedObject = (Test)super.clone();
  clonedObject.p = p; //primitive
  clonedObject.r = (Fruit)r.clone(); //reference
  return clonedObject
}

4.
/**
* @pre = (size() > 0) && (first() != null)
* @post = size()@pre - 1
* @result = first()@pre
*/
I just added checking that first() is not null on the precondition and changed the postcondition to check that size() had been decrementd and the result condition should be first()@pre instead of element(0)@pre as there is no member named element().

DISCLAIMER: However confident I feel about my answers (and I do fee confident), I take no responsibility for their correctness or accuracy.
Re: Mock exam paper answers ?
October 30, 2007 02:36PM
For question 4 Esckay wrote:
> 4. /**
> * @pre = size() > 0
> * @post = size()@pre + 1
> * @result = element(0)@pre
> */

@pre size() > 0
@post size() = size() @pre + 1

The Multiple Choice question 3 is a bit of a nasty one. You could almost be tempted to select option 2 - Data members of the instance a. Which is not exactly true (perhaps a string representation of the criticaldata members if toString() has been overridden.) but is close enough.

Stevenv is spot on with answers - and I'm glad someone is confident.
Am I the only one REALLY not looking forward to this.
Re: Mock exam paper answers ?
October 30, 2007 03:16PM
IMHO, the postcondition of size@pre+1 is incorrect as they're asking for the contract of dequeue() which removes the object at the front of the queue and returns the object. This contract would imply that after the method is invoked, there is one extra element in the queue i.e. size before the method is invoked plus one. I would say that it is rather the case that the size will be one less as an element was removed.

Question 3 of the MCQ was a little tricky, I must be honest that I had to try it out on a Java compiler to get the answer but I knew it had to be either 3 or 4. couldn't be 1 as the reference is not null and couldn't be 2 because toString on Object isn't intelligent enough to automatically print out its fields or those of subclasses and we weren't told wether ReadingMaterial was overriding toString() or not.
Re: Mock exam paper answers ?
October 30, 2007 03:25PM
Yip - looking at the post condition again - you are quite correct, it should be size() == size()@pre - 1

Sorry for the confusion.
Re: Mock exam paper answers ?
October 30, 2007 03:41PM
Thanks Steven.

And NO Andrew, you are not the only NOT looking forward to this. The assignments was fine, because there is a computer and not time constraint ... unlike the exam !!!

Good luck to you all !
Re: Mock exam paper answers ?
October 30, 2007 06:20PM
To make it worse, a storm has just killed our power.
I'm finding it hard enough to motivate myself for this subject (that I don't care much for to begin with), I really son't see myself battling at this by candlelight. Any other subject but this one.
I suppose it's about how bad you want it..... it's going to be a long dark night.
avatar Re: Mock exam paper answers ?
October 30, 2007 07:26PM
at least you can still study winking smiley i must shower and go write the exam now sad smiley
avatar Re: Mock exam paper answers ?
October 30, 2007 07:30PM
Lyc, maybe you can give some hints after the paper smile

Good luck to everyone. I'm writing 3 papers in a row this week. yawning smiley
avatar Re: Mock exam paper answers ?
October 30, 2007 07:55PM
thanks, g'luck to you too!

btw, my next exams:

MAT307Y 12 NOV 2007 09:00-11:00 - discrete maths 2, combinatorics and graph theory (aaaaaaargh)
COS332A 15 NOV 2007 09:00-12:00 - numerical methods 2, partial differential equations and whatnot
COS301Y 19 NOV 2007 09:00-11:00 - theoretical cs 3 sad smiley

ouch, ouch, ouch. at least there's a bit of time to start studying...
Re: Mock exam paper answers ?
October 30, 2007 08:03PM
Good luck man !!!

And those exam hints ..... they'll really be appreciated smile , just kidding ... but if you have some .... I'll take it smile

Does anyone know if Will we have to do some of the graphics stuff in applets for the exam ?
avatar Re: Mock exam paper answers ?
October 30, 2007 08:12PM
they've asked us to learn awt stuff, but i haven't sad smiley there's just way too much of it.
Re: Mock exam paper answers ?
October 30, 2007 08:32PM
I seriously doubt there will be any AWT or Swing as it wasn't covered in any of the assignments (and no mention in the exam tut letter). I also can't imagine there will be anything on applets as there is no point in coding an applet when you can't see what the result is, but then again ...
avatar Re: Mock exam paper answers ?
October 30, 2007 08:57PM
Oh boy thats a hectic Lyc. You better start soon. I don't have any time left. After tomorrow I got INF 307 & 308 on thursday and friday respectively. They aren't that bad but 308 seems a bit scary to me. Don't sleep too late guys. I'm to bed in an hour. No use breaking my head for the paper now.
Re: Mock exam paper answers ?
October 30, 2007 08:59PM
Damn - my excuse is gone - the power is back on.

All the best Lycium, let us know how it went.
Re: Mock exam paper answers ?
October 30, 2007 09:11PM
Why are you having to go write now???
Re: Mock exam paper answers ?
October 30, 2007 09:33PM
He has immigrated to New Zealand, i.e. a couple of hours ahead of us.
Re: Mock exam paper answers ?
October 30, 2007 09:40PM
Funny, because as I saw his comment, I went onto the class list and saw his details say Pretoria. Obviously hasn't been updated yet. Well, good luck to him. On a different note, I hear there are PLENTY I.T. jobs in NZ, particularly in Wellington. A cousin has just returned from there (holiday), she says she could deinitely live there.
Anonymous User
Re: Mock exam paper answers ?
October 30, 2007 09:48PM
i wonder if we will get the same exam as those in NZ.
Re: Mock exam paper answers ?
October 30, 2007 09:55PM
I would think we would, otherwise it would be different standards for different students.
Anonymous User
Re: Mock exam paper answers ?
October 30, 2007 10:00PM
but you can still test the same objectives with different questions. How is it going with the studies. I am struggling to get the design patterns in my head I am starting to compare them to silly stuff like Template class have words like hook and skeleton-like pirates=template
Re: Mock exam paper answers ?
October 30, 2007 10:09PM
I am slowing down now. This subject has always concerned me. Sometimes exams have a way of leaving you thinking you have failed outright, and then you get a pass mark! I am hoping for that. Would prefer feeling I did well, and then still passing, but not expecting to. I would just like to get this subject behind me. Haven't enjoyed it.
Re: Mock exam paper answers ?
October 30, 2007 10:10PM
And you?
Anonymous User
Re: Mock exam paper answers ?
October 30, 2007 10:16PM
Well I do not want to fail but if I do it is my own doing. I did concentrate all my energy on this subject. I only have submitted one assignment due to my work condition I could not complete the rest.So I have to get something above 56% for the exam to pass this subject. Currently I can not concentrate on any studying.
Re: Mock exam paper answers ?
October 30, 2007 10:22PM
I must say, this is not the most pleasant subject around. .... and I despise have to write code on paper.

The programming part here is not so bad, I actually did well in all the assignments, but the is with Intellisense and autocomplete and more than 3 hours to figure it out smile

The design patterns are giving me a bit of hell though, and if they will be asking stuff on the frameworks and collections, then I think I am slightly skrewed.

Generally I get good grades (even scored well on COS211 last year), but for this one I would be happy just with a pass.

Well, back to the design patterns for me.

Good luck to everyone tomorrow !!
Anonymous User
Re: Mock exam paper answers ?
October 30, 2007 10:26PM
Well I have only read through ch 11 and 8 all my concentration is on Ch 6 & 7. I did make summaries of all the other chapters but it does not help you if you do not study them
Re: Mock exam paper answers ?
October 30, 2007 10:26PM
Well, that is tough. I didn't submit assignment 4, and so I managed to get 4% towards my final mark, but I might be wrong, but I think now I have to get 51% for my exam. This is because the exam mark only carries a weight of 90 (out of 100). Anyway, good luck for tomorrow. Nothing more that can be done now.
Sorry, only registered users may post in this forum.

Click here to login