• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Mock Question - Inheritance

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Q)You are designing an application to recommend dog breeds to potential pet owners. To maximize the advantage of working in an object-oriented language, you have created a Dog class, which will be extended by classes representing different kinds of dogs. The following code fragment shows the class declaration and all of the instance variables in the Dog class: 1. public class Dog extends Object { 2. float avgWeight; 3. float avgLifespan; 4. String breedName; Which of the following would be reasonable variable declarations for the SportingDog class, which extends Dog? [Check all correct answers]
A) private float avgWeight ;
B) private Dog theDog ;
C) String[] hunts ;
D) String breedName ;
Answer Given : C
What can be the possible answer??
Mukti
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mukti
a. FALSE - field already exists in superclass
b. FALSE - same as above
c. TRUE - new field to hold an array of what the sporting dog
hunts
d. FALSE - field already exists in the superclass
A subclass is a specialization of the it's superclass; it reasonable to add new fields.
Hope that helps
------------------
Jane Griscti
Sun Certified Java 2 Programmer
"When ideas fail, words come in very handy" -- Goethe
 
reply
    Bookmark Topic Watch Topic
  • New Topic