Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Bottom class that extends the Top class. The Bottom class must be concr

ID: 3865600 • Letter: C

Question

Create a Bottom class that extends the Top class. The Bottom class must be concrete. The class should have a single constructor that takes two input parameters: a String (for name) and int (for age). The foo method of Bottom should print (to standard output) the object’s name and age. A Bottom object also has boolean attribute called middle that should be assigned to true when an abject is created. This is a simple question please answer according to instructions

Code should be indented after abstract class Top

code

public abstract class Top{

private int x = 12;

protected String name;

public int age;

public Top(String name){

this.name = name; //make sure to indent this block of code

age = 0;

System.out.println(x);

}

public abstract void foo(String f);

}

Explanation / Answer

public class Bottom extends Top{


    boolean middle;
  
    public Bottom(String name,int age ) {
        super(name);
        this.name=name;
        this.age=age;
        middle=true;
    }

    @Override
    public void foo(String f) {
        System.out.println("Name :- "+name+" age :- "+age);
    }
  
}