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

java 12) What is the access specifier for all methods in every Java interface? _

ID: 3834506 • Letter: J

Question

java

12) What is the access specifier for all methods in every Java interface? ______

13) Write the copy constructor for this DVD class: (write your code below the code I wrote)

public class DVD

{

          private String title;

          private double cost;

          private int quantity;

          public DVD( )

          {

                     title = “unknown”;

                     cost = 0;

                     quantity = 0;

          }

         

          public DVD(String inTitle, double inCost, int inQuantity)

          {

                     title = new String(inTitle);

                     cost = inCost;

                     quantity = inQuantity;

           }

          //write your copy constructor here

14) Does the DVD class shown above use aggregation? (yes or no)

Explanation / Answer

Please find the below solutionb of above problem statement:

12) What is the access specifier for all methods in every Java interface? ______
Ans:- public
Expalnation: in interface all methods are implicitly public in java, means if u dont write public modifier no issue:
public interface Test{
                   //it will work fine , compiler will add impplicitly piblic modifier
           void method1();
               //works fine
               public void method2();
           }
13) Write the copy constructor for this DVD class: (write your code below the code I wrote)

public class DVD
{
private String title;
private double cost;
private int quantity;

public DVD( )
{
title = “unknown”;
cost = 0;
quantity = 0;
}

public DVD(String inTitle, double inCost, int inQuantity)
{
title = new String(inTitle);
cost = inCost;
quantity = inQuantity;
}

// copy constructor
       //passing the DVD class object
       public DVD(DVD object)
       {
                   title=object.title;
                   cost=object.cost;
                   quantity=object.quantity;
       }
}

14) Does the DVD class shown above use aggregation? (yes or no)
   yes
   aggregation represents HAS-A relationship
   means a class have another class reference
   in the above DVD class
   DVD class has a String title