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

Please label your answers (as which one is for which question or which part of w

ID: 3851924 • Letter: P

Question



Please label your answers (as which one is for which question or which part of which question, such as 1 A 1B..., etc.) and please use separate paragraphs for your answers to individual questions or individual parts of each question Thank you for your co-operation Let us analyze the following two Java classes. They work together public class CompanyTest public static void main(String args! ID Company c1 new Company( Company c2 new Company[ C223", 200000.50, 50) System.out.printin("Byel) j ilend main 1 llend class In a separate java file public class Company private String colD private String coName private double revenue2011 private int totNoFTEmployees If Constructor 1 public Company (String iniD String inName, double inRev int inEmp) publiec Company (String iniD. String inName, double inRev int inEmp) c010-inID coName inName revenue2011 =inRev; totNoFTEmployees = inEmp /Constructor 2 public Company (String inName, String inlD, double inRev int inEmp) coName inName, revenue2011 FinRev totNoFTEmployees FinEmp

Explanation / Answer

1. If we compile the above code, it throws

error: constructor Company(String,String,double,int) is already defined in class Company

Since constructor 1 and constructor 2 both are same, they conflicts each other which results in error.

2. Commenting or removing either Constructor 1 or Constructor 2 will fix the code.

//Constructor 2
   /*public Company(String inName, String inID, double inRev, int inEmp)
   {
       coID = inID;
       coName = inName;
       revenue2011 = inRev;
       totNoFTEmployees = inEmp;
   }*/