Java Reference
In-Depth Information
Review Questions
1.
Where does the term polymorphism originate?
2.
What is the only effect that the abstract keyword has on a class?
3.
What are the two main effects of declaring a method abstract?
Use the following three class definitions to answer the remaining questions.
//filename: Mammal.java
public abstract class Mammal
{
public void breathe()
{
System.out.println(“Mammal is breathing”);
}
public abstract void nurse();
}
//filename: Cat.java
public class Cat extends Mammal
{
public void breathe()
{
System.out.println(“Cat is breathing”);
}
public void nurse(int t)
{
System.out.println(“Cat is nursing”);
}
}
//filename: Whale.java
public class Whale extends Mammal
{
public void breathe()
{
System.out.println(“Whale is breathing”);
super.breathe();
}
public void nurse()
{
System.out.println(“Whale is nursing”);
}
}
Search WWH ::




Custom Search