Explain the is-a and has-a relationship between classes used in inheritance and in composition.

What will be an ideal response?


If the inheritance is properly done, an object of class D that is derived from class B will be an object of class B. One author puts this relationship as “is substitutable for”. If an object of class B can be used in a context, then any object of class D must be substitutable for the class B object. It would be wrong to derive a class car from class engine. A car is not an engine. We cannot substitute a car for an engine. On the other hand, if we make a class engine object a member of our class car, we say the car object has-a(n) engine. Moral: Take great care in building inheritance relationships.

Computer Science & Information Technology

You might also like to view...

If the file has not been saved before, the ____ window appears.

A. Save B. Name File C. Save As D. Save File

Computer Science & Information Technology

Consider a 2-by-3 integer array t.

a) Write a declaration for t. b) How many rows does t have? c) How many columns does t have? d) How many elements does t have? e) Write the names of all the elements in row 1 of t. f) Write the names of all the elements in column 2 of t. g) Write a statement that sets the element of t in the first row and second column to zero. h) Write a series of statements that initialize each element of t to zero. Do not use a loop. i) Write a nested counter-controlled for statement that initializes each element of t to zero. j) Write a nested range-based for statement that initializes each element of t to zero.

Computer Science & Information Technology

What are the two main reasons to you should set up an NPS architecture with RADIUS when you have different connection paths to your network?

What will be an ideal response?

Computer Science & Information Technology

The correlation name is also known as a(n) ___________.

a. alias b. alternative c. substitute d. pseudo name

Computer Science & Information Technology