Knowee
Questions
Features
Study Tools

public abstract interface Insurance{public void insuranceDescription(String s);} Which is the correct class? Select one:a.public abstract class Car implements Insurance{ public abstract void insuranceDescription (String s) { }}b.public abstract class Car implements Insurance { }c.public class Car extends Insurance{public void insuranceDescription (Integer i) { }}d.public class Car implements Insurance{public void insuranceDescription (Integer i) { }}

Question

public abstract interface Insurance{public void insuranceDescription(String s);} Which is the correct class? Select one:a.public abstract class Car implements Insurance{ public abstract void insuranceDescription (String s) { }}b.public abstract class Car implements Insurance { }c.public class Car extends Insurance{public void insuranceDescription (Integer i) { }}d.public class Car implements Insurance{public void insuranceDescription (Integer i) { }}

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct class is:

b. public abstract class Car implements Insurance { }

Explanation:

Option a is incorrect because you cannot have an abstract method in a class with a body. Abstract methods are declared without an implementation.

Option c is incorrect because a class cannot extend an interface, it can only implement an interface.

Option d is incorrect because the method insuranceDescription in the class Car is not properly overriding the method from the interface Insurance. The parameter type should be String, not Integer.

Option b is correct because it is an abstract class that implements the Insurance interface. It doesn't provide the implementation of the insuranceDescription method, which is acceptable because it's an abstract class.

This problem has been solved

Similar Questions

Assume few interfaces, Loan and Insurance and a class Bike.Also lets define a class BenelliBike. Establish relationship between BenelliBike and Bike, Loan and Insurance.public interface Loan {    //some methods}public interface Insurance  {    //some methods}public class Bike  {    //some code}public class BenelliBike   blank  blank  blank  blank{    //some code}implements Loan,Insurance Bike  extends

Observe the below code :abstract public class Phone  {         private String model;         private double cost;}public class SmartPhone extends Phone{          private String cameraDetails;}Which of the below are valid declarations ?Select one or more:Phone phoneObj = new SmartPhone();SmartPhone phoneObj = new SmartPhone();SmartPhone phoneObj = new Phone();SmartPhone phoneObj = new Phone();Phone ph = (Phone)phoneObj;Phone phoneObj = new Phone();Phone phoneObj = new SmartPhone();SmartPhone smartph = (SmartPhone) phoneObj

Observe the below code.  You have a class InsurancePolicy and another class VehicleInsurancePolicy that inherits InsurancePolicy.InsurancePolicy.javapublic class InsurancePolicy { private int policyNumber; private String holderName; private double amount; double calculateBonusAmount(){ //some logic return 0; } }VehicleInsurancePolicy.javaclass VehicleInsurancePolicy extends InsurancePolicy { private String vehicleNumber; private int noOfMonths;   double calculateBonusAmount(){ //some logic return 0; }}Which access specifier can be given to the overridden method calculateBonusAmount.

Predict the outputclass Car implements Insurance{        public int calcPremium(int i)    {        return i = i * i;    }}interface Insurance{    int calcPremium(int i);}public class MainClass {    public static void main(String[] args)    {        Insurance b = new Car();        System.out.println(b.calcPremium(2));    }}Select one:a.The output will be 4b.Compile time error because you must create interface before implementing it.c.Compile time error because you cannot create an object of type interface Insuranced.Run time Error

Which statements are true for both abstract classes and interfaces? (Choose all that apply  *4 pointsA. All methods within them are assumed to be abstract.B. Both can contain public static final variables.C. Both can be extended using the extend keyword.D. Both can contain default methods.E. Both can contain static methods.F. Neither can be instantiated directly.G. Both inherit java.lang.Object.

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.