8. What is the purpose of using an \"abstract\" class when using inheritance? Wh
ID: 3748989 • Letter: 8
Question
8. What is the purpose of using an "abstract" class when using inheritance? When a method is defined as "abstract", what must the programmer make sure to do? What is the one thing you cannot do with abstract classes? 9 What is the dilfference between overriding and overloading? Provide examples to explain the difference. 10. Consider the following two classes. public class Dog public class UnderDog extends Dog public void acto public void acto System.out print(run):( eato: super act): System.out print sleep public void eat0 public void eat0 System.out printear): super.eato System.out print bark) Assume that the following declaration appears in a client program Dog fido - new UnderDogl: new UnderDogl: What is printed as a result of the ca fido.act)? Output:Explanation / Answer
Answer 8:
if we are inheriting from any abstract class than we must make the child class alos anstract if we dont override all abstract methods
When method is abstract than class must be made as abstract
for abstract classes we can not create the instances
Answer 9
overloading : same method name with different type of,order of, numbet of parametrs
Overriding : redifing the parent class method defination in child class is known as method overriding
Overloading example:
class Arith{
public void sum(int a,int b){
}
public void sum(float a,float b){
}
}
Overriding example:
class Parent{
public void fun(){
System.out.println("Parent");
}
}
class Child extends Parent{
public void fun(){
System.out.println("Child");
}
}
Answer 10:
run eat sleep
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.