How does abstract class differs from a regular class


Problem:

Question 1- What is an abstract class and how does it differs from a regular class?

Question 2- Why are abstract class constructors defined as protected?

Question 3- Class X defines method M1( ) as abstract. Class Y inherits from Class X and implements the method M1( ). Given the following code, explain why a reference to the abstract class X is allowed to refer to an object of the concrete class Y. Explain what happens when the reference to the abstract class X is used to execute method M1( ).

X obj = new Y( );

obj.M1( );

Question 4- What are interfaces allowed containing?

Question 5- Define a simple interface named Motorized with one method (maxSpeed) which returns the maximum attainable speed and another method (fuelType) which returns the type of fuel required.

Question 6- Given the interface defined in question 5, if a class named Motorcycle implements this interface, explain why the following code is legal. What happens when the interface reference vehicle invokes the maxSpeed method?

Motorized vehicle = new Motorcycle( );

System.out.print(“The max speed is %d\n”, vehicle.maxSpeed( ) );

Please explain abstract class and how does it differs from a regular class.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: How does abstract class differs from a regular class
Reference No:- TGS0892886

Expected delivery within 24 Hours