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

i just need the answer for the question i do not need the code in java program.

ID: 3700714 • Letter: I

Question

i just need the answer for the question i do not need the code in java program.

Lab Report Questions

Is it possible to create an instance of an interface?

How many classes can any class inherit? How many interfaces can a class implement?

Objective:

Write a class that uses the shape interface to now draw a diamond

First download the driver and put it in your project

DO NOT ALTER THE DRIVER!

Also download the ShapeBasics and ShapeInterface to use in your code

Write an INTERFACE called DiamondInterface which inherits from ShapeInterface

Create the following method definitions

setWidth – this method is used to set the width of the diamond

Write a class file called Diamond that DOES NOT HAVE a main method

This class implements the DiamondInterface and inherits from ShapeBasics

Some of the attributes of Diamond are

width – that represents the width of the triangle that has to be odd

Create the following ConstructorsDefault – sets everything to default values

width = 0

One that has the parameters

Offset – used in the parent class

width

Accessors and Mutators for each variable

MAKE SURE THE MUTATORS CHECK FOR VALID VALUES!

Create the following Methods

setWidth – this sets the width of the diamond. This must be implemented just like the interface. This number must be odd.

drawHere – this draws the diamond and overrides the method in ShapeBasics

drawTopV – this private method draws the top part of the diamond

drawBottomV – this private method draws the bottom part of the diamond

Create the following static methods

skipSpaces – this takes in a certain number of spaces to skip which means drawing “ “.

Example Dialog:

Welcome to the diamond drawer

Enter the diamond size followed by the offset or 0 to quit

7

1

    *

   * *

*   *

*     *

*   *

   * *

    *

Enter the diamond size followed by the offset or 0 to quit

0

0

bye!

Lab Report Questions

Is it possible to create an instance of an interface?

How many classes can any class inherit? How many interfaces can a class implement?

Explanation / Answer

yes it is possible to create an instance of a interface but if we want to use its method we have to define it when we instantiate it as :---------- >>>

interface Test { public void wish(); } class Main { public static void main(String[] args) { Test t=new Test() { public void wish() { System.out.println("output: hello how r u"); } }; t.wish(); } }  

this above code will work and print output: hello how r u

only one class can be inherit from any class as java does not provide multiple inheritance

you can implements any number of interface in a class you can also extends any number of interface in a interface

java allow this to acheive the power of multiple inheritance