• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

KAM India Edition Question 6.27

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given the following code, which statements are true ?
public interface HeavenlyBody {String describe();}
class Star implements HeavenlyBody {
String starname;
public String describe() { return "star" + starname;}
}
class Planet {
String name;
Star Orbitting ;
public String describe() {
return "planet"+name+"orbiting"+orbiting.describe();
}
}
Select all valid answers
a) The code will fail to compile
b) The use of aggregation is justified, since plant has-a star.
c) The code will fail to compile if the name starName is replaced with the name bodyName throughout the Star class definition.
d) The code will fail to compile if the name starName is replaced with the name name throughout the Star class definition.
e) An instance of Planet is a valid instance of a HeavenlyBody.
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI!
Given the following code, which statements are true ?
public interface HeavenlyBody {String describe();}
class Star implements HeavenlyBody {
String starname;
public String describe() { return "star" + starname;}
}
class Planet {
String name;
Star Orbitting ;
public String describe() {
return "planet"+name+"orbiting"+orbiting.describe();
}
}
Select all valid answers
a) The code will fail to compile
b) The use of aggregation is justified, since plant has-a star.
c) The code will fail to compile if the name starName is replaced with the name bodyName throughout the Star class definition.
d) The code will fail to compile if the name starName is replaced with the name name throughout the Star class definition.
e) An instance of Planet is a valid instance of a HeavenlyBody.
THe code will fail to compile stating that class or variable orbitting is not defined.
 
Mahesh Bansal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code will compile but throw an error at run time.
Mahesh
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is KAM India (is it a mock exam on web? Can you tell the site or email me at [email protected]
Thanks
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only correct answer is option b.
 
shabbir zakir
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
The code will fail to compile stating that undefined variable or class orbiting on Line 10.
 
The moustache of a titan! The ad of a flea:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic