This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes KAM India Edition Question 6.27 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "KAM India Edition Question 6.27" Watch "KAM India Edition Question 6.27" New topic
Author

KAM India Edition Question 6.27

Mahesh Bansal
Ranch Hand

Joined: Nov 28, 2000
Posts: 82
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.
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
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

Joined: Nov 28, 2000
Posts: 82
The code will compile but throw an error at run time.
Mahesh
Sandeep Chaturvedi
Greenhorn

Joined: Jan 19, 2001
Posts: 22
What is KAM India (is it a mock exam on web? Can you tell the site or email me at chaturs@hotmail.com
Thanks
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
The only correct answer is option b.

Sun Certified Programmer for Java 2 Platform
shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi!
The code will fail to compile stating that undefined variable or class orbiting on Line 10.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: KAM India Edition Question 6.27
 
Similar Threads
Another question from Khalid
is-a question
Help needed on Inheritance
why would this code run without an error?
looking at this code, why Planet class is not a Star class?