What is wrong with the following code public abstract class

What is wrong with the following code: public abstract class Chair {private double seatHeight = 24; ||... public Chair() {||...} public abstract sit() {}; public double get SeatHeight() {return seatHeight;}} Extra {} after the abstract method sit (abstract methods have no method body) O Constructor not needed for abstract class getSeatHeight must be abstract (no abstract methods allowed in abstract class) class Chair cannot be abstract

Solution

Answer :

Wrong statement is

Extra {} in the abstract method sit(abstract method have no method body)

The corrected code

public abstract void sit(); // no method body,only semicolon

 What is wrong with the following code: public abstract class Chair {private double seatHeight = 24; ||... public Chair() {||...} public abstract sit() {}; publ

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site