Question: 1: What is an abstract class and an abstract method? Explain using the below code. 2: What is an interface? How are they different from

1: What is an abstract class and an abstract method? Explain using the below code. 

2: What is an interface? How are they different from abstract classes? Explain using the below code. 

3: Explain the difference between the three access types public, private and protected. Explain briefly using the below code. 

4: Write an example class that uses both the abstract class and the interface. Just the minimum skeleton of the required functions need to be shown. Body of the function need not be shown. Just the relevant details need to be shown.

3 4 2 public abstract class Room { protected double length; protected

3 4 2 public abstract class Room { protected double length; protected double width; protected double height; protected int numOfDoors = 1; protected int numOfWindows; 5 6 7 8 90 10 11 12 13 14 15 16 17 18 19 200 public Room( double 1, double w, double h, int now) { length = 1; width = w; height = h; numOfWindows = now; 29 30 } } /* gets and sets are not shown here */| abstract public double calcFloor Area(); abstract public double calcWallArea(); public String toString() { //Not completed. String retStr = ""; return retStr; 21 22 23 24 25 } 26 27 interface Plumbing{ 28 } public static final String agency = "Broward Water Agency"; public abstract boolean setWaterConnection();

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Solution An abstract class is a class that cannot be instantiated and serves as a base for other classes to extend from It contains abstract methods that do not have an implementation in the abstract ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!