bab 12

29 Jun

1. Describe the three characteristic features of object-oriented languages.
inheritance : abilities to derive a data member to another class.
polymorphism : including overiding and overloading.
encapsulation : abilities to make ADT.

2. What is the difference between a class variable and an instance variable?
class variable have an access modifier, usually private.
instance variable doesn’t have an access modifier.

3. What is multiple inheritance?
a class which is derived from multiple class.

4. What is a polymorphic variable?
it have an abstract data type

5. What is an overriding method?
a method which is existing in both base & derived class, with a different parameter
in the derived class. the one in derived class is called the overiding one.

6. Describe a situation where dynamic binding is a great advantage over its absence.
when it is not clear how much data there are.

7. What is a virtual method?
a method that binded in the run time. when needed.

8. What is an abstract method? What is an abstract class?
abstract method is a method with no body,
abstract class is a class containing abstract method

10. What is a nesting class?
The class in which the new class is nested is called the nesting class.

11. What is the message protocol of an object?
The entire collection of methods of an object is called the message protocol

24. What is a friend function in C++ ?
a function that can accessed by it friend class.

25. What is a pure virtual function in C++ ?
an abstract virtual method

19. How are C++ heap-allocated objects deallocated?
by using delete.

problem set

10. Explain one disadvantage of inheritance.
it kinda raise an objection to the rule data member being a private member.

11. Explain the advantages and disadvantages of having all values in a
language be objects.
advantages: it will be flexible.
disadvantages: it will be too time consuming

12. What exactly does it mean for a subclass to have an is-a relationship with
its parent class?
the base class is an abstract class for it derived class.

13. Describe the issue of how closely the parameters of an overriding
method must match those of the method it overrides.
it must be exactly the same order, type, amount of parameter.

16. What is the primary reason why all Java objects have a common ancestor?
so the classes object can be accessed by the base class object when passed by
reference in a function.

17. What is the purpose of the finalize clause in Java?
A finalize method is implicitly called when the garbage collector is about
to reclaim the storage occupied by the object.

18. What would be gained if Java allowed stack-dynamic objects, as well as
heap-dynamic objects? What would be the disadvantage of having both?
the disadvantages is another garbage collecting code is needed for two dynamic object


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: