QUESTION 6 Which of the following would be an appropriate Superclass for the fol
ID: 3877529 • Letter: Q
Question
QUESTION 6
Which of the following would be an appropriate Superclass for the following subclasses?
Truck Ambulance Bus
a.
Car
b.
Driver
c.
Vehicle
d.
Train
QUESTION 7
Chapter 7 uses the following hierarchy:
Images intégrées 2
Leaf classes are concrete while all non-leaf classes are abstract. Which of the following object-method pairs would require dynamic binding? (Multiple Answers)
a.
Object Type Method Name
Rectangle getPerimeterLength
b.
Object Type Method Name
SimplePolygon getCenter
c.
Object Type Method Name
Polygon getBoundingRect
d.
Object Type Method Name
EllipticalShape changeScale
e.
Object Type Method Name
RegularPolygon translate
QUESTION 8
Questions 8, 9 and 10 uses the following heiarchy:
Images intégrées 1
Which of the following methods in PostalCode would most appropriately be implemented as abstract?
a.
getCode
b.
getDestination
c.
validate
d.
setDestination
QUESTION 9
Which of the following classes would most likely be implemented as abstract?
a.
PostalCodeException
b.
PostalTest
c.
CanadianPostalCode
d.
PostalCode
QUESTION 10
Which of the following classes most like be implemented as final?
a.
PostalCode
b.
USZipCode
c.
Either a or b could be implemented as final
d.
Neither a or b could ever be implemented as final
QUESTION 8 Questions 8, 9 and 10 uses the following heiarchy PostalCode PostalTest toString() gekCode) getDestination) setDestination validate) PostalCodeException moin gerCountry0 BritishPostalCode validate gelCountry) CanadianPostalCode validate) gelCountry0) USZipCode validate() gelCountry)Explanation / Answer
6) answer is option c - vehicle. because vehical superclass refers all type of automobiles. and other option refers only one type of automobiles.
7)override- when method in subclass has same name and same signature as method it its superclass then method in subclass is called overriden method. In dynamic binding - call to overriden method is resolved at run time .
object type Rectangle ---- Method name - getPerimeterLength()-- Dynamic binding is required. getPerimeterlength() is declacred in both superclass - Shape2D and subclass- Rectangle.
object type SimplePolygon---- Method name -getCenter()--- Dynamic Binding is not required. getCenter() is only declared in superclass Shape2D class not in subclass SimplePolygon .so no overridden. so dynamic programming.
object type polygon ---- method name -- getBoundaryRec()-- dynamic binding is required because this method is overriden .
object type--EllipticalShape----- method name---changeScale()--- dynamic binding is not required. becauese this method is only declared in superclass Shape2D.
object type regularPolygon ---- method name---translate()... dynamic binding is required.. because it is declared in both superclass Shape2D and subclass -- RegularPolygon
8) validate method can be implemented as abstract method. because it is being implemented in 3 different classes .
9) abstract class - it may or may not contain abstract method but it must be inherited. so in given option. PostalCode class can be abstract class
10) USZipCode class can be final class. becausefinal class can not be inherited but final class can be subclass.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.