1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
skad [1K]
3 years ago
13

Provide instance fields for title, month, and year (for example, "Scientific American", "April", 2020). Each of these should be

accessible only within the Magazine class.Create a constructor, which initializes the instance fieldsWrite a toString() method, modeled after the standard Java toString() method, to return a String representation of the Magazine.Write an equals() method, modeled after the standard Java equals() method. Two Magazines are equal if they have the same title, month, and year.HTML EditorKeyboard Shortcuts

Computers and Technology
1 answer:
miskamm [114]3 years ago
4 0

Answer:

Check the explanation

Explanation:

Note : check attached image for output and program and also note that you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

Program : **************Magzine.java**********************

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class Magzine {

 

//class variable private can not access outside class

private String title;

private String month;

private int year;

 

//parameterized constructor

public Magzine(String title,String month,int year)

{

this.title=title;

this.month=month;

this.year=year;

}

 

//override toString method

"at"Override

public String toString()

{

String detail=title+" "+month+" "+Integer.toString(year);

return detail;//return string of class variable

}

 

//get Magzine objecte

 

public boolean equals(Magzine obj)

{

//commented returm statement compare string by address so you can uncomment if

//we do not use same string object of String class

//return this.month==obj.month && this.title==obj.title && this.year==obj.year;

//compare two object element if matches return true else false

return (this.month.equals(obj.month)) &&(this.title.equals(obj.title)) && this.year==obj.year;

}

   

}

Program : *************************Main.java****************************

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

public class Main {

/**

* "at"param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Magzine Obj =new Magzine("Scientific American ", "April", 2020); //object of class

Magzine Obj1 =new Magzine("Scientific American ", "April", 2020);//Obj and obj1 is same content data

Magzine Obj2 =new Magzine("Scientific American", "June", 2020); //obj and obj1 same but obj2 different

 

System.out.println(Obj.toString()); //print string of obj

System.out.println(Obj1.toString());//print string of obj1

System.out.println(Obj2.toString());//print string of obj2

 

 

System.out.println(Obj.equals(Obj1)); //obj and obj1 equal and return true

System.out.println(Obj.equals(Obj2)); // obj and obj2 not equal so return false

 

 

}

 

}

Output can be seen below:

You might be interested in
You have a Windows system that has both wired and wireless network connections. The wired connection is on the internal private
Oksana_A [137]

Answer: D. Enable the remote Assistance exception only on the private profile

Explanation:

4 0
2 years ago
Conduct a site research on a specific property using the concepts discussed during this week.
Anni [7]

Answer:Penis!

Explanation:

Haha! Enjoy your day! Hahahahaha!

8 0
2 years ago
Select the correct answer.
Nady [450]

Answer:

B

Explanation:

In an ERD, the Crow Foot Notation Symbols are used with cardinality.

Hope it helps you

3 0
2 years ago
Select the correct text in the passage.
grin007 [14]

Answer: Because it is known for that

Explanation:

I think it would be The Hawaiian islands are known for their volcanic activities

8 0
2 years ago
What solicits online input such as product ratings from consumers?
Pie

Answer:

Crowdsourcing I think is the correct answer. "A quick response code" and "Computer Forensics" both don't make sense as answers, and Crowdfunding is specifically for money.

7 0
2 years ago
Other questions:
  • Here are the codes for producer and consumer problems.
    10·1 answer
  • At what point is an idea protected by copyright?
    7·2 answers
  • 3.
    13·1 answer
  • Which of the following can you use to attach external hardware devices to a computer?
    11·2 answers
  • Students who respond promptly to e-mails are following which netiquette rule?
    13·2 answers
  • An inventory clerk, using a computer terminal, views the following on screen: part number, part description, quantity on hand, q
    8·1 answer
  • The following are reasons why many organizations are trying to reduce and right-size their information foot-print by using data
    10·1 answer
  • Jasmine wants electrical current to be able to pass through a certain switch on a circuit board that she is designing. What stat
    5·1 answer
  • What are the 3 dimension of an information system?
    13·1 answer
  • Explain why a holiday on a cruise liner will be an ideal holiday​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!